summaryrefslogtreecommitdiff
path: root/packages/client/src/components
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-06-25 18:26:34 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-06-25 18:26:34 +0900
commit929dc076ec700d3fdfc8c9606303c427a13c6196 (patch)
tree506990802acc04179fcfa42278919e4ca205c713 /packages/client/src/components
parentfeat: allow GET for some endpoints (diff)
parentrefactor: notification setting window composition API (#8860) (diff)
downloadmisskey-929dc076ec700d3fdfc8c9606303c427a13c6196.tar.gz
misskey-929dc076ec700d3fdfc8c9606303c427a13c6196.tar.bz2
misskey-929dc076ec700d3fdfc8c9606303c427a13c6196.zip
Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
Diffstat (limited to 'packages/client/src/components')
-rw-r--r--packages/client/src/components/notification-setting-window.vue116
1 files changed, 51 insertions, 65 deletions
diff --git a/packages/client/src/components/notification-setting-window.vue b/packages/client/src/components/notification-setting-window.vue
index 64d828394b..84550c9da1 100644
--- a/packages/client/src/components/notification-setting-window.vue
+++ b/packages/client/src/components/notification-setting-window.vue
@@ -6,95 +6,81 @@
:with-ok-button="true"
:ok-button-disabled="false"
@ok="ok()"
- @close="$refs.dialog.close()"
- @closed="$emit('closed')"
+ @close="dialog.close()"
+ @closed="emit('closed')"
>
- <template #header>{{ $ts.notificationSetting }}</template>
+ <template #header>{{ i18n.ts.notificationSetting }}</template>
<div class="_monolithic_">
<div v-if="showGlobalToggle" class="_section">
<MkSwitch v-model="useGlobalSetting">
- {{ $ts.useGlobalSetting }}
- <template #caption>{{ $ts.useGlobalSettingDesc }}</template>
+ {{ i18n.ts.useGlobalSetting }}
+ <template #caption>{{ i18n.ts.useGlobalSettingDesc }}</template>
</MkSwitch>
</div>
<div v-if="!useGlobalSetting" class="_section">
- <MkInfo>{{ $ts.notificationSettingDesc }}</MkInfo>
- <MkButton inline @click="disableAll">{{ $ts.disableAll }}</MkButton>
- <MkButton inline @click="enableAll">{{ $ts.enableAll }}</MkButton>
- <MkSwitch v-for="type in notificationTypes" :key="type" v-model="typesMap[type]">{{ $t(`_notification._types.${type}`) }}</MkSwitch>
+ <MkInfo>{{ i18n.ts.notificationSettingDesc }}</MkInfo>
+ <MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
+ <MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
+ <MkSwitch v-for="type in notificationTypes" :key="type" v-model="typesMap[type]">{{ i18n.t(`_notification._types.${type}`) }}</MkSwitch>
</div>
</div>
</XModalWindow>
</template>
-<script lang="ts">
-import { defineComponent, PropType } from 'vue';
+<script lang="ts" setup>
+import { PropType } from 'vue';
import { notificationTypes } from 'misskey-js';
import MkSwitch from './form/switch.vue';
import MkInfo from './ui/info.vue';
import MkButton from './ui/button.vue';
import XModalWindow from '@/components/ui/modal-window.vue';
+import { i18n } from '@/i18n';
-export default defineComponent({
- components: {
- XModalWindow,
- MkSwitch,
- MkInfo,
- MkButton,
- },
+const emit = defineEmits<{
+ (ev: 'done', v: { includingTypes: string[] | null }): void,
+ (ev: 'closed'): void,
+}>();
- props: {
- includingTypes: {
- // TODO: これで型に合わないものを弾いてくれるのかどうか要調査
- type: Array as PropType<typeof notificationTypes[number][]>,
- required: false,
- default: null,
- },
- showGlobalToggle: {
- type: Boolean,
- required: false,
- default: true,
- },
- },
-
- emits: ['done', 'closed'],
+const props = withDefaults(defineProps<{
+ // TODO: これで型に合わないものを弾いてくれるのかどうか要調査
+ includingTypes?: typeof notificationTypes[number][];
+ showGlobalToggle?: boolean;
+}>(), {
+ includingTypes: () => [],
+ showGlobalToggle: true,
+});
- data() {
- return {
- typesMap: {} as Record<typeof notificationTypes[number], boolean>,
- useGlobalSetting: false,
- notificationTypes,
- };
- },
+const dialog = $ref<InstanceType<typeof XModalWindow>>();
- created() {
- this.useGlobalSetting = this.includingTypes === null && this.showGlobalToggle;
+let typesMap = $ref<Record<typeof notificationTypes[number], boolean>>({});
+let useGlobalSetting = $ref(props.includingTypes === [] && props.showGlobalToggle);
- for (const type of this.notificationTypes) {
- this.typesMap[type] = this.includingTypes === null || this.includingTypes.includes(type);
- }
- },
+for (const type of notificationTypes) {
+ typesMap[type] = props.includingTypes.includes(type);
+}
- methods: {
- ok() {
- const includingTypes = this.useGlobalSetting ? null : (Object.keys(this.typesMap) as typeof notificationTypes[number][])
- .filter(type => this.typesMap[type]);
+function ok() {
+ if (useGlobalSetting) {
+ emit('done', { includingTypes: null });
+ } else {
+ emit('done', {
+ includingTypes: (Object.keys(typesMap) as typeof notificationTypes[number][])
+ .filter(type => typesMap[type]),
+ });
+ }
- this.$emit('done', { includingTypes });
- this.$refs.dialog.close();
- },
+ dialog.close();
+}
- disableAll() {
- for (const type in this.typesMap) {
- this.typesMap[type as typeof notificationTypes[number]] = false;
- }
- },
+function disableAll() {
+ for (const type in typesMap) {
+ typesMap[type as typeof notificationTypes[number]] = false;
+ }
+}
- enableAll() {
- for (const type in this.typesMap) {
- this.typesMap[type as typeof notificationTypes[number]] = true;
- }
- },
- },
-});
+function enableAll() {
+ for (const type in typesMap) {
+ typesMap[type as typeof notificationTypes[number]] = true;
+ }
+}
</script>