From 53b21cd4558f8a8f9c0100c1da1a41066805ff5e Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Tue, 11 Apr 2023 10:12:17 -0700 Subject: [PATCH] feat: lookup post action --- locales/en-US.yml | 1 + packages/client/src/pages/admin/index.vue | 28 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index a1b998d8a..213452a51 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -963,6 +963,7 @@ indexNotice: "Now indexing. This will probably take a while, please don't restar customKaTeXMacro: "Custom KaTeX macros" customKaTeXMacroDescription: "Set up macros to write mathematical expressions easily! The notation conforms to the LaTeX command definitions and is written as \\newcommand{\\name}{content} or \\newcommand{\\name}[number of arguments]{content}. For example, \\newcommand{\\add}[2]{#1 + #2} will expand \\add{3}{foo} to 3 + foo. The curly brackets surrounding the macro name can be changed to round or square brackets. This affects the brackets used for arguments. One (and only one) macro can be defined per line, and you can't break the line in the middle of the definition. Invalid lines are simply ignored. Only simple string substitution functions are supported; advanced syntax, such as conditional branching, cannot be used here." enableCustomKaTeXMacro: "Enable custom KaTeX macros" +noteId: "Post ID" _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing NSFW media via Machine Learning. This will slightly increase the load on the server." diff --git a/packages/client/src/pages/admin/index.vue b/packages/client/src/pages/admin/index.vue index 63e4e178f..c0ac742b8 100644 --- a/packages/client/src/pages/admin/index.vue +++ b/packages/client/src/pages/admin/index.vue @@ -359,6 +359,32 @@ const invite = () => { }); }; +async function lookupNote() { + const { canceled, result: q } = await os.inputText({ + title: i18n.ts.noteId, + }); + if (canceled) return; + + os.api( + "notes/show", + q.startsWith("http://") || q.startsWith("https://") + ? { url: q.trim() } + : { noteId: q.trim() }, + ) + .then((note) => { + os.pageWindow(`/notes/${note.id}`); + }) + .catch((err) => { + if (err.code === "NO_SUCH_NOTE") { + os.alert({ + type: "error", + text: i18n.ts.notFound, + }); + } + }); +} + + const lookup = (ev) => { os.popupMenu( [ @@ -373,7 +399,7 @@ const lookup = (ev) => { text: i18n.ts.note, icon: "ph-pencil ph-bold ph-lg", action: () => { - alert("TODO"); + lookupNote(); }, }, {