feat (client): add ability to append #Alt4Me automatically

This commit is contained in:
naskya 2024-06-28 15:54:04 +09:00
parent a2e060c992
commit aa97455708
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
6 changed files with 27 additions and 7 deletions

View file

@ -1238,6 +1238,7 @@ noAltTextWarning: "Some attached file(s) have no description. Did you forget to
showNoAltTextWarning: "Show a warning if you attempt to post files without a description"
showAddFileDescriptionAtFirstPost: "Automatically open a form to write a description
when you attempt to post files without a description"
addAlt4MeTag: "Automatically append #Alt4Me hashtag to your post if attached file has no description"
_emojiModPerm:
unauthorized: "None"

View file

@ -7,7 +7,7 @@ import { alert, api, popup, popupMenu, waiting } from "@/os";
import icon from "@/scripts/icon";
import { del, get, set } from "@/scripts/idb-proxy";
import { reloadChannel, unisonReload } from "@/scripts/unison-reload";
import type { MenuButton, MenuUser } from "./types/menu";
import type { MenuUser } from "./types/menu";
// TODO: 他のタブと永続化されたstateを同期

View file

@ -1195,6 +1195,13 @@ async function post() {
}
}
if (
defaultStore.state.addAlt4MeTag &&
files.value.some((f) => f.comment == null || f.comment.length === 0)
) {
text.value = `${text.value.trimEnd()}\n#Alt4Me`;
}
const processedText = preprocess(text.value);
let postData: ApiTypes.NoteSubmitReq = {

View file

@ -127,12 +127,6 @@
<FormSwitch v-model="openServerInfo" class="_formBlock">{{
i18n.ts.openServerInfo
}}</FormSwitch>
<FormSwitch v-model="showNoAltTextWarning" class="_formBlock">{{
i18n.ts.showNoAltTextWarning
}}</FormSwitch>
<FormSwitch v-model="showAddFileDescriptionAtFirstPost" class="_formBlock">{{
i18n.ts.showAddFileDescriptionAtFirstPost
}}</FormSwitch>
<FormSwitch v-model="autocorrectNoteLanguage" class="_formBlock">{{
i18n.ts.autocorrectNoteLanguage
}}</FormSwitch>
@ -191,6 +185,15 @@
<FormSection>
<template #label>{{ i18n.ts.accessibility }}</template>
<FormSwitch v-model="showNoAltTextWarning" class="_formBlock">{{
i18n.ts.showNoAltTextWarning
}}</FormSwitch>
<FormSwitch v-if="showNoAltTextWarning" v-model="showAddFileDescriptionAtFirstPost" class="_formBlock">{{
i18n.ts.showAddFileDescriptionAtFirstPost
}}</FormSwitch>
<FormSwitch v-model="addAlt4MeTag" class="_formBlock">{{
i18n.ts.addAlt4MeTag
}}</FormSwitch>
<FormSwitch v-model="expandOnNoteClick" class="_formBlock"
>{{ i18n.ts.expandOnNoteClick
}}<template #caption>{{
@ -568,6 +571,7 @@ const mergeThreadInTimeline = computed(
const mergeRenotesInTimeline = computed(
defaultStore.makeGetterSetter("mergeRenotesInTimeline"),
);
const addAlt4MeTag = computed(defaultStore.makeGetterSetter("addAlt4MeTag"));
// This feature (along with injectPromo) is currently disabled
// function onChangeInjectFeaturedNote(v) {

View file

@ -127,6 +127,10 @@ const defaultStoreSaveKeys: (keyof (typeof defaultStore)["state"])[] = [
"showNoAltTextWarning",
"showAddFileDescriptionAtFirstPost",
"autocorrectNoteLanguage",
"addAlt4MeTag",
"addRe",
"mergeRenotesInTimeline",
"mergeThreadInTimeline",
];
const coldDeviceStorageSaveKeys: (keyof typeof ColdDeviceStorage.default)[] = [
"lightTheme",

View file

@ -449,6 +449,10 @@ export const defaultStore = markRaw(
where: "account",
default: false,
},
addAlt4MeTag: {
where: "account",
default: false,
},
autocorrectNoteLanguage: {
where: "account",
default: true,