diff options
| author | KevinWh0 <45321184+KevinWh0@users.noreply.github.com> | 2024-02-16 21:53:27 +0100 |
|---|---|---|
| committer | KevinWh0 <45321184+KevinWh0@users.noreply.github.com> | 2024-02-16 21:53:27 +0100 |
| commit | 11cb134d4d28f3e9e816affcbb1ba98d68e7d9e2 (patch) | |
| tree | 49703805799c7bcd767aa27072013d4a6723c5f6 | |
| parent | merge: Fix Note Edits being federated incorrectly (!417) (diff) | |
| download | sharkey-11cb134d4d28f3e9e816affcbb1ba98d68e7d9e2.tar.gz sharkey-11cb134d4d28f3e9e816affcbb1ba98d68e7d9e2.tar.bz2 sharkey-11cb134d4d28f3e9e816affcbb1ba98d68e7d9e2.zip | |
It works, Just figuring out some ts errors hopefully
| -rw-r--r-- | locales/en-US.yml | 4 | ||||
| -rw-r--r-- | locales/index.d.ts | 12 | ||||
| -rw-r--r-- | locales/ja-JP.yml | 3 | ||||
| -rw-r--r-- | packages/frontend/src/components/MkPostForm.vue | 35 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/general.vue | 2 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/preferences-backups.vue | 1 | ||||
| -rw-r--r-- | packages/frontend/src/store.ts | 4 |
7 files changed, 60 insertions, 1 deletions
diff --git a/locales/en-US.yml b/locales/en-US.yml index 8a32d8307c..7a9a54ed9e 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -524,6 +524,7 @@ mediaListWithOneImageAppearance: "Height of media lists with one image only" limitTo: "Limit to {x}" noFollowRequests: "You don't have any pending follow requests" openImageInNewTab: "Open images in new tab" +warnForMissingAltText: "Warn you when you forget to put alt text" dashboard: "Dashboard" local: "Local" remote: "Remote" @@ -1051,6 +1052,9 @@ thisPostMayBeAnnoying: "This note may annoy others." thisPostMayBeAnnoyingHome: "Post to home timeline" thisPostMayBeAnnoyingCancel: "Cancel" thisPostMayBeAnnoyingIgnore: "Post anyway" +thisPostIsMissingAltTextCancel: "Cancel" +thisPostIsMissingAltTextIgnore: "Post anyway" +thisPostIsMissingAltText: "One of the files attached to this post is missing alt text. Please ensure all the attachments have alt text." collapseRenotes: "Collapse boosts you've already seen" collapseFiles: "Collapse files" autoloadConversation: "Load conversation on replies" diff --git a/locales/index.d.ts b/locales/index.d.ts index 012cbe055a..c9179a2049 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -4222,6 +4222,18 @@ export interface Locale extends ILocale { */ "thisPostMayBeAnnoyingIgnore": string; /** + * Cancel + */ + "thisPostIsMissingAltTextCancel": string; + /** + * Post anyway + */ + "thisPostIsMissingAltTextIgnore": string; + /** + * One of the files attached to this post is missing alt text. Please ensure all the attachments have alt text. + */ + "thisPostIsMissingAltText": string; + /** * 見たことのあるブーストを省略して表示 */ "collapseRenotes": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 9714f8f668..e6eee1d988 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1051,6 +1051,9 @@ thisPostMayBeAnnoying: "この投稿は迷惑になる可能性があります thisPostMayBeAnnoyingHome: "ホームに投稿" thisPostMayBeAnnoyingCancel: "やめる" thisPostMayBeAnnoyingIgnore: "このまま投稿" +thisPostIsMissingAltTextCancel: "Cancel" +thisPostIsMissingAltTextIgnore: "Post anyway" +thisPostIsMissingAltText: "One of the files attached to this post is missing alt text. Please ensure all the attachments have alt text." collapseRenotes: "見たことのあるブーストを省略して表示" collapseFiles: "ファイルを折りたたむ" autoloadConversation: "返信に会話を読み込む" diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 65ffb7b7a5..25e51fd52c 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -101,7 +101,7 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script lang="ts" setup> -import { inject, watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed } from 'vue'; +import { inject, watch, nextTick, onMounted, defineAsyncComponent, provide, shallowRef, ref, computed, toRaw } from 'vue'; import * as mfm from '@transfem-org/sfm-js'; import * as Misskey from 'misskey-js'; import insertTextAtCursor from 'insert-text-at-cursor'; @@ -744,6 +744,39 @@ async function post(ev?: MouseEvent) { visibility.value = 'home'; } } + + if (defaultStore.state.warnMissingAltText) { + const filesData = toRaw(files.value); + for (let i = 0; i < filesData.length; i++) { + const file = filesData[i]; + const isMissingAltText = !file.comment; + if (isMissingAltText) { + const { canceled, result } = await os.actions({ + type: 'warning', + text: i18n.ts.thisPostIsMissingAltText, + actions: [{ + value: 'cancel', + text: i18n.ts.thisPostIsMissingAltTextCancel, + }, { + value: 'ignore', + text: i18n.ts.thisPostIsMissingAltTextIgnore, + }], + }); + + if (canceled) return; + if (result === 'cancel') return; + if (result === 'home') { + visibility.value = 'home'; + } + + // await os.alert({ + // type: 'info', + // text: i18n.ts.thisPostIsMissingAltText, + // }); + // return; + } + } + } let postData = { text: text.value === '' ? null : text.value, diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 3b2946e2b7..9247e25fc8 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -180,6 +180,7 @@ SPDX-License-Identifier: AGPL-3.0-only <div class="_gaps_m"> <div class="_gaps_s"> + <MkSwitch v-model="warnMissingAltText">{{ i18n.ts.warnForMissingAltText }}</MkSwitch> <MkSwitch v-model="imageNewTab">{{ i18n.ts.openImageInNewTab }}</MkSwitch> <MkSwitch v-model="useReactionPickerForContextMenu">{{ i18n.ts.useReactionPickerForContextMenu }}</MkSwitch> <MkSwitch v-model="enableInfiniteScroll">{{ i18n.ts.enableInfiniteScroll }}</MkSwitch> @@ -337,6 +338,7 @@ const oneko = computed(defaultStore.makeGetterSetter('oneko')); const loadRawImages = computed(defaultStore.makeGetterSetter('loadRawImages')); const highlightSensitiveMedia = computed(defaultStore.makeGetterSetter('highlightSensitiveMedia')); const imageNewTab = computed(defaultStore.makeGetterSetter('imageNewTab')); +const warnMissingAltText = computed(defaultStore.makeGetterSetter('warnMissingAltText')); const nsfw = computed(defaultStore.makeGetterSetter('nsfw')); const showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostForm')); const showFixedPostFormInChannel = computed(defaultStore.makeGetterSetter('showFixedPostFormInChannel')); diff --git a/packages/frontend/src/pages/settings/preferences-backups.vue b/packages/frontend/src/pages/settings/preferences-backups.vue index ad0903caee..9aa2012a81 100644 --- a/packages/frontend/src/pages/settings/preferences-backups.vue +++ b/packages/frontend/src/pages/settings/preferences-backups.vue @@ -71,6 +71,7 @@ const defaultStoreSaveKeys: (keyof typeof defaultStore['state'])[] = [ 'animatedMfm', 'advancedMfm', 'loadRawImages', + 'warnMissingAltText', 'imageNewTab', 'dataSaver', 'disableShowingAnimatedImages', diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index d695caa95f..a1f552487c 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -264,6 +264,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false, }, + warnMissingAltText: { + where: 'device', + default: true, + }, imageNewTab: { where: 'device', default: false, |