mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
bug fixes & improments
This commit is contained in:
11 files changed
+15
-18
No files matched your search
@@ -72,7 +72,7 @@ class DiscussionMainHandler extends Handler {
|
||||
const parentType = { $in: Object.keys(typeMapper).map((i) => typeMapper[i]) };
|
||||
all &&= this.user.hasPerm(PERM.PERM_MOD_BADGE);
|
||||
const [ddocs, dpcount] = await this.paginate(
|
||||
discussion.getMulti(domainId, { parentType, ...all ? {} : { hidden: false } }),
|
||||
discussion.getMulti(domainId, { parentType, ...all ? {} : { hidden: false } }).hint('discussionSort'),
|
||||
page,
|
||||
'discussion',
|
||||
);
|
||||
|
||||
@@ -507,6 +507,8 @@ class HomeDomainHandler extends Handler {
|
||||
|
||||
@param('id', Types.String)
|
||||
async postLeave({ }, id: string) {
|
||||
const ddoc = await domain.get(id);
|
||||
if (!ddoc) throw new NotFoundError(id);
|
||||
await domain.setJoin(id, this.user._id, false);
|
||||
this.back();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ if (process.env.NIX_PROFILES) {
|
||||
|
||||
export class Loader extends Service {
|
||||
public state: Record<string, EffectScope> = Object.create(null);
|
||||
public config: {};
|
||||
public suspend = false;
|
||||
public cache: Record<string, string> = Object.create(null);
|
||||
// public warnings: Record<string, string> = Object.create(null);
|
||||
|
||||
@@ -220,7 +220,7 @@ export async function deleteSub<T extends keyof DocType, K extends ArrayKeys<Doc
|
||||
domainId: string, docType: T, docId: DocType[T]['docId'],
|
||||
key: K, subId: MaybeArray<DocType[T][K][0]['_id']>,
|
||||
): Promise<DocType[T]> {
|
||||
subId = (subId instanceof Array) ? subId : [subId];
|
||||
subId = Array.isArray(subId) ? subId : [subId];
|
||||
return await coll.findOneAndUpdate(
|
||||
{ domainId, docType, docId },
|
||||
// @ts-ignore
|
||||
@@ -416,6 +416,7 @@ export async function apply(ctx: Context) {
|
||||
collStatus.deleteMany({ domainId }),
|
||||
]));
|
||||
await db.clearIndexes(coll, ['tag', 'hidden']);
|
||||
const onlyFor = (docType: number) => ({ partialFilterExpression: { docType } });
|
||||
await db.ensureIndexes(
|
||||
coll,
|
||||
{ key: { domainId: 1, docType: 1, docId: 1 }, name: 'basic', unique: true },
|
||||
@@ -426,8 +427,8 @@ export async function apply(ctx: Context) {
|
||||
// For problem solution
|
||||
{ key: { domainId: 1, docType: 1, parentType: 1, parentId: 1, vote: -1, docId: -1 }, name: 'solution', sparse: true },
|
||||
// For discussion
|
||||
{ key: { domainId: 1, docType: 1, pin: -1, docId: -1 }, name: 'discussionSort', sparse: true },
|
||||
{ key: { domainId: 1, docType: 1, parentType: 1, parentId: 1, pin: -1, docId: -1 }, name: 'discussionNodeSort', sparse: true },
|
||||
{ key: { docType: 1, domainId: 1, hidden: 1, pin: -1, docId: -1 }, name: 'discussionSort', ...onlyFor(TYPE_DISCUSSION) },
|
||||
{ key: { docType: 1, domainId: 1, hidden: 1, parentType: 1, parentId: 1, pin: -1, docId: -1 }, name: 'discussionNodeSort', sparse: true },
|
||||
// Hidden doc
|
||||
{ key: { domainId: 1, docType: 1, hidden: 1, docId: -1 }, name: 'hiddenDoc', sparse: true },
|
||||
// For contest
|
||||
|
||||
@@ -302,7 +302,7 @@ export async function apply(ctx: Context) {
|
||||
ctx.on('domain/delete-cache', async (domainId: string) => {
|
||||
const ddoc = await DomainModel.get(domainId);
|
||||
if (!ddoc) return;
|
||||
for (const host of ddoc.hosts || []) {
|
||||
for (const host of ddoc.host || []) {
|
||||
cache.delete(`host::${host}`);
|
||||
}
|
||||
cache.delete(`id::${domainId}`);
|
||||
|
||||
Reference in new issue
Block a user