Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
This commit is contained in:
commit
929dc076ec
|
@ -55,7 +55,7 @@
|
||||||
"json5": "2.2.1",
|
"json5": "2.2.1",
|
||||||
"json5-loader": "4.0.1",
|
"json5-loader": "4.0.1",
|
||||||
"jsonld": "6.0.0",
|
"jsonld": "6.0.0",
|
||||||
"jsrsasign": "10.5.24",
|
"jsrsasign": "10.5.25",
|
||||||
"koa": "2.13.4",
|
"koa": "2.13.4",
|
||||||
"koa-bodyparser": "4.3.0",
|
"koa-bodyparser": "4.3.0",
|
||||||
"koa-favicon": "2.1.0",
|
"koa-favicon": "2.1.0",
|
||||||
|
|
|
@ -4061,10 +4061,10 @@ jsprim@^1.2.2:
|
||||||
json-schema "0.4.0"
|
json-schema "0.4.0"
|
||||||
verror "1.10.0"
|
verror "1.10.0"
|
||||||
|
|
||||||
jsrsasign@10.5.24:
|
jsrsasign@10.5.25:
|
||||||
version "10.5.24"
|
version "10.5.25"
|
||||||
resolved "https://registry.yarnpkg.com/jsrsasign/-/jsrsasign-10.5.24.tgz#2d159e1756b2268682c6eb5e147184e33e946b1c"
|
resolved "https://registry.yarnpkg.com/jsrsasign/-/jsrsasign-10.5.25.tgz#8eb3f943718d73f2dd3d85f587f241a5316b835a"
|
||||||
integrity sha512-0i/UHRgJZifp/YmoXHyNQXUY4eKWiSd7YxuD7oKEw9mlqgr51hg9lZQw2nlEDvwHDh7pyj6ZjYlxldlW27xb/Q==
|
integrity sha512-N7zxHaCwYvFlXsybq4p4RxRwn4AbEq3cEiyjbCrWmwA7g8aS4LTKDJ9AJmsXxwtYesYx0imJ+ITtkyyxLCgeIg==
|
||||||
|
|
||||||
jstransformer@1.0.0:
|
jstransformer@1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
|
|
|
@ -6,95 +6,81 @@
|
||||||
:with-ok-button="true"
|
:with-ok-button="true"
|
||||||
:ok-button-disabled="false"
|
:ok-button-disabled="false"
|
||||||
@ok="ok()"
|
@ok="ok()"
|
||||||
@close="$refs.dialog.close()"
|
@close="dialog.close()"
|
||||||
@closed="$emit('closed')"
|
@closed="emit('closed')"
|
||||||
>
|
>
|
||||||
<template #header>{{ $ts.notificationSetting }}</template>
|
<template #header>{{ i18n.ts.notificationSetting }}</template>
|
||||||
<div class="_monolithic_">
|
<div class="_monolithic_">
|
||||||
<div v-if="showGlobalToggle" class="_section">
|
<div v-if="showGlobalToggle" class="_section">
|
||||||
<MkSwitch v-model="useGlobalSetting">
|
<MkSwitch v-model="useGlobalSetting">
|
||||||
{{ $ts.useGlobalSetting }}
|
{{ i18n.ts.useGlobalSetting }}
|
||||||
<template #caption>{{ $ts.useGlobalSettingDesc }}</template>
|
<template #caption>{{ i18n.ts.useGlobalSettingDesc }}</template>
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!useGlobalSetting" class="_section">
|
<div v-if="!useGlobalSetting" class="_section">
|
||||||
<MkInfo>{{ $ts.notificationSettingDesc }}</MkInfo>
|
<MkInfo>{{ i18n.ts.notificationSettingDesc }}</MkInfo>
|
||||||
<MkButton inline @click="disableAll">{{ $ts.disableAll }}</MkButton>
|
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
|
||||||
<MkButton inline @click="enableAll">{{ $ts.enableAll }}</MkButton>
|
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
|
||||||
<MkSwitch v-for="type in notificationTypes" :key="type" v-model="typesMap[type]">{{ $t(`_notification._types.${type}`) }}</MkSwitch>
|
<MkSwitch v-for="type in notificationTypes" :key="type" v-model="typesMap[type]">{{ i18n.t(`_notification._types.${type}`) }}</MkSwitch>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</XModalWindow>
|
</XModalWindow>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, PropType } from 'vue';
|
import { PropType } from 'vue';
|
||||||
import { notificationTypes } from 'misskey-js';
|
import { notificationTypes } from 'misskey-js';
|
||||||
import MkSwitch from './form/switch.vue';
|
import MkSwitch from './form/switch.vue';
|
||||||
import MkInfo from './ui/info.vue';
|
import MkInfo from './ui/info.vue';
|
||||||
import MkButton from './ui/button.vue';
|
import MkButton from './ui/button.vue';
|
||||||
import XModalWindow from '@/components/ui/modal-window.vue';
|
import XModalWindow from '@/components/ui/modal-window.vue';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
|
||||||
export default defineComponent({
|
const emit = defineEmits<{
|
||||||
components: {
|
(ev: 'done', v: { includingTypes: string[] | null }): void,
|
||||||
XModalWindow,
|
(ev: 'closed'): void,
|
||||||
MkSwitch,
|
}>();
|
||||||
MkInfo,
|
|
||||||
MkButton,
|
|
||||||
},
|
|
||||||
|
|
||||||
props: {
|
const props = withDefaults(defineProps<{
|
||||||
includingTypes: {
|
|
||||||
// TODO: これで型に合わないものを弾いてくれるのかどうか要調査
|
// TODO: これで型に合わないものを弾いてくれるのかどうか要調査
|
||||||
type: Array as PropType<typeof notificationTypes[number][]>,
|
includingTypes?: typeof notificationTypes[number][];
|
||||||
required: false,
|
showGlobalToggle?: boolean;
|
||||||
default: null,
|
}>(), {
|
||||||
},
|
includingTypes: () => [],
|
||||||
showGlobalToggle: {
|
showGlobalToggle: true,
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['done', 'closed'],
|
|
||||||
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
typesMap: {} as Record<typeof notificationTypes[number], boolean>,
|
|
||||||
useGlobalSetting: false,
|
|
||||||
notificationTypes,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
|
||||||
this.useGlobalSetting = this.includingTypes === null && this.showGlobalToggle;
|
|
||||||
|
|
||||||
for (const type of this.notificationTypes) {
|
|
||||||
this.typesMap[type] = this.includingTypes === null || this.includingTypes.includes(type);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
ok() {
|
|
||||||
const includingTypes = this.useGlobalSetting ? null : (Object.keys(this.typesMap) as typeof notificationTypes[number][])
|
|
||||||
.filter(type => this.typesMap[type]);
|
|
||||||
|
|
||||||
this.$emit('done', { includingTypes });
|
|
||||||
this.$refs.dialog.close();
|
|
||||||
},
|
|
||||||
|
|
||||||
disableAll() {
|
|
||||||
for (const type in this.typesMap) {
|
|
||||||
this.typesMap[type as typeof notificationTypes[number]] = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
enableAll() {
|
|
||||||
for (const type in this.typesMap) {
|
|
||||||
this.typesMap[type as typeof notificationTypes[number]] = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const dialog = $ref<InstanceType<typeof XModalWindow>>();
|
||||||
|
|
||||||
|
let typesMap = $ref<Record<typeof notificationTypes[number], boolean>>({});
|
||||||
|
let useGlobalSetting = $ref(props.includingTypes === [] && props.showGlobalToggle);
|
||||||
|
|
||||||
|
for (const type of notificationTypes) {
|
||||||
|
typesMap[type] = props.includingTypes.includes(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ok() {
|
||||||
|
if (useGlobalSetting) {
|
||||||
|
emit('done', { includingTypes: null });
|
||||||
|
} else {
|
||||||
|
emit('done', {
|
||||||
|
includingTypes: (Object.keys(typesMap) as typeof notificationTypes[number][])
|
||||||
|
.filter(type => typesMap[type]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableAll() {
|
||||||
|
for (const type in typesMap) {
|
||||||
|
typesMap[type as typeof notificationTypes[number]] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableAll() {
|
||||||
|
for (const type in typesMap) {
|
||||||
|
typesMap[type as typeof notificationTypes[number]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue