merge: upstream

This commit is contained in:
Marie 2023-12-23 02:09:23 +01:00
commit 5db583a3eb
701 changed files with 50809 additions and 13660 deletions

View file

@ -32,13 +32,11 @@ import { i18n } from '@/i18n.js';
import MkInfo from '@/components/MkInfo.vue';
import MkSuperMenu from '@/components/MkSuperMenu.vue';
import { signout, $i } from '@/account.js';
import { unisonReload } from '@/scripts/unison-reload.js';
import { clearCache } from '@/scripts/clear-cache.js';
import { instance } from '@/instance.js';
import { useRouter } from '@/router.js';
import { definePageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata.js';
import * as os from '@/os.js';
import { miLocalStorage } from '@/local-storage.js';
import { fetchCustomEmojis } from '@/custom-emojis.js';
const indexInfo = {
title: i18n.ts.settings,
@ -51,14 +49,14 @@ const childInfo = ref(null);
const router = useRouter();
let narrow = $ref(false);
const narrow = ref(false);
const NARROW_THRESHOLD = 600;
let currentPage = $computed(() => router.currentRef.value.child);
const currentPage = computed(() => router.currentRef.value.child);
const ro = new ResizeObserver((entries, observer) => {
if (entries.length === 0) return;
narrow = entries[0].borderBoxSize[0].inlineSize < NARROW_THRESHOLD;
narrow.value = entries[0].borderBoxSize[0].inlineSize < NARROW_THRESHOLD;
});
const menuDef = computed(() => [{
@ -67,37 +65,37 @@ const menuDef = computed(() => [{
icon: 'ph-user ph-bold ph-lg',
text: i18n.ts.profile,
to: '/settings/profile',
active: currentPage?.route.name === 'profile',
active: currentPage.value?.route.name === 'profile',
}, {
icon: 'ph-lock ph-bold ph-lg-open',
text: i18n.ts.privacy,
to: '/settings/privacy',
active: currentPage?.route.name === 'privacy',
active: currentPage.value?.route.name === 'privacy',
}, {
icon: 'ph-smiley ph-bold ph-lg',
text: i18n.ts.reaction,
to: '/settings/reaction',
active: currentPage?.route.name === 'reaction',
text: i18n.ts.emojiPicker,
to: '/settings/emoji-picker',
active: currentPage.value?.route.name === 'emojiPicker',
}, {
icon: 'ph-cloud ph-bold ph-lg',
text: i18n.ts.drive,
to: '/settings/drive',
active: currentPage?.route.name === 'drive',
active: currentPage.value?.route.name === 'drive',
}, {
icon: 'ph-bell ph-bold ph-lg',
text: i18n.ts.notifications,
to: '/settings/notifications',
active: currentPage?.route.name === 'notifications',
active: currentPage.value?.route.name === 'notifications',
}, {
icon: 'ph-envelope ph-bold ph-lg',
text: i18n.ts.email,
to: '/settings/email',
active: currentPage?.route.name === 'email',
active: currentPage.value?.route.name === 'email',
}, {
icon: 'ph-lock ph-bold ph-lg',
text: i18n.ts.security,
to: '/settings/security',
active: currentPage?.route.name === 'security',
active: currentPage.value?.route.name === 'security',
}],
}, {
title: i18n.ts.clientSettings,
@ -105,32 +103,32 @@ const menuDef = computed(() => [{
icon: 'ph-faders ph-bold ph-lg',
text: i18n.ts.general,
to: '/settings/general',
active: currentPage?.route.name === 'general',
active: currentPage.value?.route.name === 'general',
}, {
icon: 'ph-palette ph-bold ph-lg',
text: i18n.ts.theme,
to: '/settings/theme',
active: currentPage?.route.name === 'theme',
active: currentPage.value?.route.name === 'theme',
}, {
icon: 'ph-list ph-bold ph-lg-2',
text: i18n.ts.navbar,
to: '/settings/navbar',
active: currentPage?.route.name === 'navbar',
active: currentPage.value?.route.name === 'navbar',
}, {
icon: 'ph-equals ph-bold ph-lg',
text: i18n.ts.statusbar,
to: '/settings/statusbar',
active: currentPage?.route.name === 'statusbar',
active: currentPage.value?.route.name === 'statusbar',
}, {
icon: 'ph-music-notes ph-bold ph-lg',
text: i18n.ts.sounds,
to: '/settings/sounds',
active: currentPage?.route.name === 'sounds',
active: currentPage.value?.route.name === 'sounds',
}, {
icon: 'ph-plug ph-bold ph-lg',
text: i18n.ts.plugins,
to: '/settings/plugin',
active: currentPage?.route.name === 'plugin',
active: currentPage.value?.route.name === 'plugin',
}],
}, {
title: i18n.ts.otherSettings,
@ -138,56 +136,50 @@ const menuDef = computed(() => [{
icon: 'ph-seal-check ph-bold ph-lg',
text: i18n.ts.roles,
to: '/settings/roles',
active: currentPage?.route.name === 'roles',
active: currentPage.value?.route.name === 'roles',
}, {
icon: 'ph-prohibit ph-bold ph-lg',
text: i18n.ts.muteAndBlock,
to: '/settings/mute-block',
active: currentPage?.route.name === 'mute-block',
active: currentPage.value?.route.name === 'mute-block',
}, {
icon: 'ph-key ph-bold ph-lg',
text: 'API',
to: '/settings/api',
active: currentPage?.route.name === 'api',
active: currentPage.value?.route.name === 'api',
}, {
icon: 'ph-webhooks-logo ph-bold ph-lg',
text: 'Webhook',
to: '/settings/webhook',
active: currentPage?.route.name === 'webhook',
active: currentPage.value?.route.name === 'webhook',
}, {
icon: 'ph-package ph-bold ph-lg',
text: i18n.ts.importAndExport,
to: '/settings/import-export',
active: currentPage?.route.name === 'import-export',
active: currentPage.value?.route.name === 'import-export',
}, {
icon: 'ph-airplane ph-bold ph-lg',
text: `${i18n.ts.accountMigration}`,
to: '/settings/migration',
active: currentPage?.route.name === 'migration',
active: currentPage.value?.route.name === 'migration',
}, {
icon: 'ph-dots-three ph-bold ph-lg',
text: i18n.ts.other,
to: '/settings/other',
active: currentPage?.route.name === 'other',
active: currentPage.value?.route.name === 'other',
}],
}, {
items: [{
icon: 'ph-floppy-disk ph-bold ph-lg',
text: i18n.ts.preferencesBackups,
to: '/settings/preferences-backups',
active: currentPage?.route.name === 'preferences-backups',
active: currentPage.value?.route.name === 'preferences-backups',
}, {
type: 'button',
icon: 'ph-trash ph-bold ph-lg',
text: i18n.ts.clearCache,
action: async () => {
os.waiting();
miLocalStorage.removeItem('locale');
miLocalStorage.removeItem('theme');
miLocalStorage.removeItem('emojis');
miLocalStorage.removeItem('lastEmojisFetchedAt');
await fetchCustomEmojis(true);
unisonReload();
await clearCache();
},
}, {
type: 'button',
@ -205,23 +197,23 @@ const menuDef = computed(() => [{
}],
}]);
watch($$(narrow), () => {
watch(narrow, () => {
});
onMounted(() => {
ro.observe(el.value);
narrow = el.value.offsetWidth < NARROW_THRESHOLD;
narrow.value = el.value.offsetWidth < NARROW_THRESHOLD;
if (!narrow && currentPage?.route.name == null) {
if (!narrow.value && currentPage.value?.route.name == null) {
router.replace('/settings/profile');
}
});
onActivated(() => {
narrow = el.value.offsetWidth < NARROW_THRESHOLD;
narrow.value = el.value.offsetWidth < NARROW_THRESHOLD;
if (!narrow && currentPage?.route.name == null) {
if (!narrow.value && currentPage.value?.route.name == null) {
router.replace('/settings/profile');
}
});
@ -231,7 +223,7 @@ onUnmounted(() => {
});
watch(router.currentRef, (to) => {
if (to.route.name === 'settings' && to.child?.route.name == null && !narrow) {
if (to.route.name === 'settings' && to.child?.route.name == null && !narrow.value) {
router.replace('/settings/profile');
}
});
@ -243,12 +235,13 @@ provideMetadataReceiver((info) => {
childInfo.value = null;
} else {
childInfo.value = info;
INFO.value.needWideArea = info.value.needWideArea ?? undefined;
}
});
const headerActions = $computed(() => []);
const headerActions = computed(() => []);
const headerTabs = $computed(() => []);
const headerTabs = computed(() => []);
definePageMetadata(INFO);
// w 890