ui: bug fixes

This commit is contained in:
undefined committed 2023-03-17 16:27:12 +08:00
1 parent b355a869b4
commit e78925c082
15 files changed
+76 -54

No files matched your search

+4 -1
View File
@@ -5,6 +5,7 @@ import type fs from 'fs';
import type { Dictionary, NumericDictionary } from 'lodash';
import type { Binary, FindCursor, ObjectId } from 'mongodb';
import type { Context } from './context';
import type { DocStatusType } from './model/document';
import type { ProblemDoc } from './model/problem';
import type { Handler } from './service/server';
@@ -649,7 +650,9 @@ declare module './service/db' {
'domain.user': any;
'record': RecordDoc;
'document': any;
'document.status': StatusDocBase;
'document.status': StatusDocBase & {
[K in keyof DocStatusType]: { docType: K } & DocStatusType[K];
}[keyof DocStatusType];
'discussion.history': DiscussionHistoryDoc;
'user': Udoc;
'user.preference': UserPreferenceDoc;
+2
View File
@@ -44,6 +44,7 @@ export interface DocType {
export interface DocStatusType {
[TYPE_PROBLEM]: ProblemStatusDoc,
// FIXME: this need to be typed
[key: number]: any
}
@@ -396,6 +397,7 @@ export async function revPushStatus<T extends keyof DocStatusType>(
if (!res.value) {
res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
// @ts-ignore
{ $push: { [key]: value }, $inc: { rev: 1 } },
{ upsert: true, returnDocument: 'after' },
);
+3 -2
View File
@@ -5,7 +5,8 @@ import { EventMap } from './bus';
import type { Handler } from './server';
type MethodDecorator = (target: any, funcName: string, obj: any) => any;
type ClassDecorator = <T extends new (...args: any[]) => any>(Class: T) => T extends new (...args: infer R) => infer S ? (...args: R) => S : never;
type ClassDecorator = <T extends new (...args: any[]) => any>(Class: T) => T extends new (...args: infer R) => infer S
? new (...args: R) => S : never;
export interface ParamOption<T> {
name: string,
source: 'all' | 'get' | 'post' | 'route',
@@ -85,7 +86,7 @@ export const post: DescriptorBuilder = (name, ...args) => _descriptor(_buildPara
export const route: DescriptorBuilder = (name, ...args) => _descriptor(_buildParam(name, 'route', ...args));
export const param: DescriptorBuilder = (name, ...args) => _descriptor(_buildParam(name, 'all', ...args));
export const subscribe: (name: keyof EventMap) => MethodDecorator | ClassDecorator = (name) => (target, funcName, obj) => {
export const subscribe: (name: keyof EventMap) => MethodDecorator & ClassDecorator = (name) => (target, funcName?, obj?) => {
if (funcName) {
target.__subscribe ||= [];
target.__subscribe.push({ name, target: obj.value });