core: fix when tsdoc doesn't exist

This commit is contained in:
undefined committed 2021-07-05 11:48:10 +08:00
1 parent c5f9f86dd7
commit b8c67114e1
3 files changed
+6 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.29.19",
"version": "2.29.20",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+4 -1
View File
@@ -91,7 +91,10 @@ export class ProblemMainHandler extends ProblemHandler {
if (sort) pdocs = pdocs.sort((a, b) => sort.indexOf(a.docId) - sort.indexOf(b.docId));
if (q) {
const pdoc = await problem.get(domainId, +q || q, problem.PROJECTION_LIST);
if (pdoc) pdocs.filter((doc) => doc.docId !== pdoc.docId).unshift(pdoc);
if (pdoc) {
pdocs = pdocs.filter((doc) => doc.docId !== pdoc.docId);
pdocs.unshift(pdoc);
}
}
if (this.user.hasPriv(PRIV.PRIV_USER_PROFILE)) {
psdict = await problem.getListStatus(
+1 -1
View File
@@ -245,7 +245,7 @@ export async function getVnode(domainId: string, type: number, id: string, uid?:
if (!tdoc) throw new DiscussionNodeNotFoundError(id);
if (uid) {
const tsdoc = await model.getStatus(domainId, _id, uid);
tdoc.attend = tsdoc.attend || tsdoc.enroll;
tdoc.attend = tsdoc?.attend || tsdoc?.enroll;
}
return { ...tdoc, type, id };
}