feat: lookup post action

This commit is contained in:
ThatOneCalculator 2023-04-11 10:12:17 -07:00
parent b6d2b15948
commit 6b359071be
No known key found for this signature in database
GPG key ID: 8703CACD01000000
2 changed files with 28 additions and 1 deletions

View file

@ -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."

View file

@ -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();
},
},
{