diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-04-08 21:27:21 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-08 21:27:21 +0900 |
| commit | a096f621cf5a47c3330935c2b9b5bfe54dfc0091 (patch) | |
| tree | b3b6a1a1ce5105091bebc80b96cfd5a73402da80 /packages/frontend/src/scripts | |
| parent | Merge pull request #10402 from misskey-dev/develop (diff) | |
| parent | [ci skip] Update CHANGELOG.md (diff) | |
| download | misskey-a096f621cf5a47c3330935c2b9b5bfe54dfc0091.tar.gz misskey-a096f621cf5a47c3330935c2b9b5bfe54dfc0091.tar.bz2 misskey-a096f621cf5a47c3330935c2b9b5bfe54dfc0091.zip | |
Merge pull request #10506 from misskey-dev/develop
13.11.0
Diffstat (limited to 'packages/frontend/src/scripts')
| -rw-r--r-- | packages/frontend/src/scripts/achievements.ts | 3 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/get-note-menu.ts | 12 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/hpml/evaluator.ts | 9 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/hpml/index.ts | 3 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/hpml/type-checker.ts | 9 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/test-utils.ts | 6 |
6 files changed, 15 insertions, 27 deletions
diff --git a/packages/frontend/src/scripts/achievements.ts b/packages/frontend/src/scripts/achievements.ts index c77f8e12d3..25e8b71a12 100644 --- a/packages/frontend/src/scripts/achievements.ts +++ b/packages/frontend/src/scripts/achievements.ts @@ -443,11 +443,14 @@ export const ACHIEVEMENT_BADGES = { bg: 'linear-gradient(0deg, rgb(144, 224, 255), rgb(255, 168, 252))', frame: 'bronze', }, +/* @see <https://github.com/misskey-dev/misskey/pull/10365#discussion_r1155511107> } as const satisfies Record<typeof ACHIEVEMENT_TYPES[number], { img: string; bg: string | null; frame: 'bronze' | 'silver' | 'gold' | 'platinum'; }>; + */ +} as const; export const claimedAchievements: typeof ACHIEVEMENT_TYPES[number][] = ($i && $i.achievements) ? $i.achievements.map(x => x.name) : []; diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 00f2523bf9..d91f0b0eb6 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -15,7 +15,7 @@ import { clipsCache } from '@/cache'; export async function getNoteClipMenu(props: { note: misskey.entities.Note; isDeleted: Ref<boolean>; - currentClipPage?: Ref<misskey.entities.Clip>; + currentClip?: misskey.entities.Clip; }) { const isRenote = ( props.note.renote != null && @@ -42,7 +42,7 @@ export async function getNoteClipMenu(props: { }); if (!confirm.canceled) { os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id }); - if (props.currentClipPage?.value.id === clip.id) props.isDeleted.value = true; + if (props.currentClip?.id === clip.id) props.isDeleted.value = true; } } else { os.alert({ @@ -92,7 +92,7 @@ export function getNoteMenu(props: { translation: Ref<any>; translating: Ref<boolean>; isDeleted: Ref<boolean>; - currentClipPage?: Ref<misskey.entities.Clip>; + currentClip?: misskey.entities.Clip; }) { const isRenote = ( props.note.renote != null && @@ -176,7 +176,7 @@ export function getNoteMenu(props: { } async function unclip(): Promise<void> { - os.apiWithDialog('clips/remove-note', { clipId: props.currentClipPage.value.id, noteId: appearNote.id }); + os.apiWithDialog('clips/remove-note', { clipId: props.currentClip.id, noteId: appearNote.id }); props.isDeleted.value = true; } @@ -230,7 +230,7 @@ export function getNoteMenu(props: { menu = [ ...( - props.currentClipPage?.value.userId === $i.id ? [{ + props.currentClip?.userId === $i.id ? [{ icon: 'ti ti-backspace', text: i18n.ts.unclip, danger: true, @@ -294,7 +294,7 @@ export function getNoteMenu(props: { text: i18n.ts.muteThread, action: () => toggleThreadMute(true), }), - appearNote.userId === $i.id ? ($i.pinnedNoteIds || []).includes(appearNote.id) ? { + appearNote.userId === $i.id ? ($i.pinnedNoteIds ?? []).includes(appearNote.id) ? { icon: 'ti ti-pinned-off', text: i18n.ts.unpin, action: () => togglePin(false), diff --git a/packages/frontend/src/scripts/hpml/evaluator.ts b/packages/frontend/src/scripts/hpml/evaluator.ts index 7bddd3f62d..9adfba7f27 100644 --- a/packages/frontend/src/scripts/hpml/evaluator.ts +++ b/packages/frontend/src/scripts/hpml/evaluator.ts @@ -1,4 +1,3 @@ -import autobind from 'autobind-decorator'; import { ref, Ref, unref } from 'vue'; import { collectPageVars } from '../collect-page-vars'; import { initHpmlLib } from './lib'; @@ -51,7 +50,6 @@ export class Hpml { this.eval(); } - @autobind public eval() { try { this.vars.value = this.evaluateVars(); @@ -60,7 +58,6 @@ export class Hpml { } } - @autobind public interpolate(str: string) { if (str == null) return null; return str.replace(/{(.+?)}/g, match => { @@ -69,12 +66,10 @@ export class Hpml { }); } - @autobind public registerCanvas(id: string, canvas: any) { this.canvases[id] = canvas; } - @autobind public updatePageVar(name: string, value: any) { const pageVar = this.pageVars.find(v => v.name === name); if (pageVar !== undefined) { @@ -84,13 +79,11 @@ export class Hpml { } } - @autobind public updateRandomSeed(seed: string) { this.opts.randomSeed = seed; this.envVars.SEED = seed; } - @autobind private _interpolateScope(str: string, scope: HpmlScope) { return str.replace(/{(.+?)}/g, match => { const v = scope.getState(match.slice(1, -1).trim()); @@ -98,7 +91,6 @@ export class Hpml { }); } - @autobind public evaluateVars(): Record<string, any> { const values: Record<string, any> = {}; @@ -117,7 +109,6 @@ export class Hpml { return values; } - @autobind private evaluate(expr: Expr, scope: HpmlScope): any { if (isLiteralValue(expr)) { if (expr.type === null) { diff --git a/packages/frontend/src/scripts/hpml/index.ts b/packages/frontend/src/scripts/hpml/index.ts index 587c6a36c8..994f286b9f 100644 --- a/packages/frontend/src/scripts/hpml/index.ts +++ b/packages/frontend/src/scripts/hpml/index.ts @@ -2,7 +2,6 @@ * Hpml */ -import autobind from 'autobind-decorator'; import { Hpml } from './evaluator'; import { funcDefs } from './lib'; @@ -61,7 +60,6 @@ export class HpmlScope { this.name = name ?? 'anonymous'; } - @autobind public createChildScope(states: Record<string, any>, name?: HpmlScope['name']): HpmlScope { const layer = [states, ...this.layerdStates]; return new HpmlScope(layer, name); @@ -71,7 +69,6 @@ export class HpmlScope { * 指定した名前の変数の値を取得します * @param name 変数名 */ - @autobind public getState(name: string): any { for (const later of this.layerdStates) { const state = later[name]; diff --git a/packages/frontend/src/scripts/hpml/type-checker.ts b/packages/frontend/src/scripts/hpml/type-checker.ts index 692826fc90..ea8133f297 100644 --- a/packages/frontend/src/scripts/hpml/type-checker.ts +++ b/packages/frontend/src/scripts/hpml/type-checker.ts @@ -1,4 +1,3 @@ -import autobind from 'autobind-decorator'; import { isLiteralValue } from './expr'; import { funcDefs } from './lib'; import { envVarsDef } from '.'; @@ -23,7 +22,6 @@ export class HpmlTypeChecker { this.pageVars = pageVars; } - @autobind public typeCheck(v: Expr): TypeError | null { if (isLiteralValue(v)) return null; @@ -61,7 +59,6 @@ export class HpmlTypeChecker { return null; } - @autobind public getExpectedType(v: Expr, slot: number): Type { const def = funcDefs[v.type ?? '']; if (def == null) { @@ -89,7 +86,6 @@ export class HpmlTypeChecker { } } - @autobind public infer(v: Expr): Type { if (v.type === null) return null; if (v.type === 'text') return 'string'; @@ -144,7 +140,6 @@ export class HpmlTypeChecker { } } - @autobind public getVarByName(name: string): Variable { const v = this.variables.find(x => x.name === name); if (v !== undefined) { @@ -154,25 +149,21 @@ export class HpmlTypeChecker { } } - @autobind public getVarsByType(type: Type): Variable[] { if (type == null) return this.variables; return this.variables.filter(x => (this.infer(x) === null) || (this.infer(x) === type)); } - @autobind public getEnvVarsByType(type: Type): string[] { if (type == null) return Object.keys(envVarsDef); return Object.entries(envVarsDef).filter(([k, v]) => v === null || type === v).map(([k, v]) => k); } - @autobind public getPageVarsByType(type: Type): string[] { if (type == null) return this.pageVars.map(v => v.name); return this.pageVars.filter(v => type === v.type).map(v => v.name); } - @autobind public isUsedName(name: string) { if (this.variables.some(v => v.name === name)) { return true; diff --git a/packages/frontend/src/scripts/test-utils.ts b/packages/frontend/src/scripts/test-utils.ts new file mode 100644 index 0000000000..3e018f2d7e --- /dev/null +++ b/packages/frontend/src/scripts/test-utils.ts @@ -0,0 +1,6 @@ +/// <reference types="@testing-library/jest-dom"/> + +export async function tick(): Promise<void> { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + await new Promise((globalThis.requestIdleCallback ?? setTimeout) as never); +} |