mirror of
https://github.com/sim1222/misskey.git
synced 2025-08-04 07:26:29 +09:00
fix: i/notificationsで古い通知タイプを許容するなど、古い通知タイプの清算 (#10042)
* wip * fix * create migration * oops * fix front const * changelog * fix type * fix * wip * Revert "wip" This reverts commit 6cdb3600e280be3550b8b6353b2c7930f7b31438. * enumのこす * fix --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
:with-ok-button="true"
|
||||
:ok-button-disabled="false"
|
||||
@ok="ok()"
|
||||
@close="dialog.close()"
|
||||
@close="dialog?.close()"
|
||||
@closed="emit('closed')"
|
||||
>
|
||||
<template #header>{{ i18n.ts.notificationSetting }}</template>
|
||||
@ -25,7 +25,7 @@
|
||||
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
|
||||
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
|
||||
</div>
|
||||
<MkSwitch v-for="ntype in notificationTypes" :key="ntype" v-model="typesMap[ntype]">{{ i18n.t(`_notification._types.${ntype}`) }}</MkSwitch>
|
||||
<MkSwitch v-for="ntype in notificationTypes" :key="ntype" v-model="typesMap[ntype].value">{{ i18n.t(`_notification._types.${ntype}`) }}</MkSwitch>
|
||||
</template>
|
||||
</div>
|
||||
</MkSpacer>
|
||||
@ -33,14 +33,16 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { } from 'vue';
|
||||
import { notificationTypes } from 'misskey-js';
|
||||
import { ref, Ref } from 'vue';
|
||||
import MkSwitch from './MkSwitch.vue';
|
||||
import MkInfo from './MkInfo.vue';
|
||||
import MkButton from './MkButton.vue';
|
||||
import MkModalWindow from '@/components/MkModalWindow.vue';
|
||||
import { notificationTypes } from '@/const';
|
||||
import { i18n } from '@/i18n';
|
||||
|
||||
type TypesMap = Record<typeof notificationTypes[number], Ref<boolean>>
|
||||
|
||||
const emit = defineEmits<{
|
||||
(ev: 'done', v: { includingTypes: string[] | null }): void,
|
||||
(ev: 'closed'): void,
|
||||
@ -54,39 +56,35 @@ const props = withDefaults(defineProps<{
|
||||
showGlobalToggle: true,
|
||||
});
|
||||
|
||||
let includingTypes = $computed(() => props.includingTypes ?? []);
|
||||
let includingTypes = $computed(() => props.includingTypes?.filter(x => notificationTypes.includes(x)) ?? []);
|
||||
|
||||
const dialog = $shallowRef<InstanceType<typeof MkModalWindow>>();
|
||||
|
||||
let typesMap = $ref<Record<typeof notificationTypes[number], boolean>>({});
|
||||
const typesMap: TypesMap = notificationTypes.reduce((p, t) => ({ ...p, [t]: ref<boolean>(includingTypes.includes(t)) }), {} as any);
|
||||
let useGlobalSetting = $ref((includingTypes === null || includingTypes.length === 0) && props.showGlobalToggle);
|
||||
|
||||
for (const ntype of notificationTypes) {
|
||||
typesMap[ntype] = includingTypes.includes(ntype);
|
||||
}
|
||||
|
||||
function ok() {
|
||||
if (useGlobalSetting) {
|
||||
emit('done', { includingTypes: null });
|
||||
} else {
|
||||
emit('done', {
|
||||
includingTypes: (Object.keys(typesMap) as typeof notificationTypes[number][])
|
||||
.filter(type => typesMap[type]),
|
||||
.filter(type => typesMap[type].value),
|
||||
});
|
||||
}
|
||||
|
||||
dialog.close();
|
||||
if (dialog) dialog.close();
|
||||
}
|
||||
|
||||
function disableAll() {
|
||||
for (const type in typesMap) {
|
||||
typesMap[type as typeof notificationTypes[number]] = false;
|
||||
for (const type of notificationTypes) {
|
||||
typesMap[type].value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function enableAll() {
|
||||
for (const type in typesMap) {
|
||||
typesMap[type as typeof notificationTypes[number]] = true;
|
||||
for (const type of notificationTypes) {
|
||||
typesMap[type].value = true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onUnmounted, onMounted, computed, shallowRef } from 'vue';
|
||||
import { notificationTypes } from 'misskey-js';
|
||||
import MkPagination, { Paging } from '@/components/MkPagination.vue';
|
||||
import XNotification from '@/components/MkNotification.vue';
|
||||
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
|
||||
@ -26,6 +25,7 @@ import XNote from '@/components/MkNote.vue';
|
||||
import { stream } from '@/stream';
|
||||
import { $i } from '@/account';
|
||||
import { i18n } from '@/i18n';
|
||||
import { notificationTypes } from '@/const';
|
||||
|
||||
const props = defineProps<{
|
||||
includeTypes?: typeof notificationTypes[number][];
|
||||
|
Reference in New Issue
Block a user