merge: Warn when missing alt text (!423)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/423 Approved-by: Amelia Yukii <amelia.yukii@shourai.de> Approved-by: Marie <marie@kaifa.ch>
This commit is contained in:
commit
15665d1533
7 changed files with 50 additions and 1 deletions
|
@ -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,29 @@ async function post(ev?: MouseEvent) {
|
|||
visibility.value = 'home';
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultStore.state.warnMissingAltText) {
|
||||
const filesData = toRaw(files.value);
|
||||
|
||||
const isMissingAltText = filesData.some(file => !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;
|
||||
}
|
||||
}
|
||||
|
||||
let postData = {
|
||||
text: text.value === '' ? null : text.value,
|
||||
|
|
|
@ -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>
|
||||
|
@ -336,6 +337,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'));
|
||||
|
|
|
@ -71,6 +71,7 @@ const defaultStoreSaveKeys: (keyof typeof defaultStore['state'])[] = [
|
|||
'animatedMfm',
|
||||
'advancedMfm',
|
||||
'loadRawImages',
|
||||
'warnMissingAltText',
|
||||
'imageNewTab',
|
||||
'dataSaver',
|
||||
'disableShowingAnimatedImages',
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue