refactor
This commit is contained in:
parent
d69f7baaf5
commit
94d4f8271e
@ -29,7 +29,7 @@ import { stream } from '@/stream';
|
|||||||
import * as sound from '@/scripts/sound';
|
import * as sound from '@/scripts/sound';
|
||||||
import { $i, refreshAccount, login, updateAccount, signout } from '@/account';
|
import { $i, refreshAccount, login, updateAccount, signout } from '@/account';
|
||||||
import { defaultStore, ColdDeviceStorage } from '@/store';
|
import { defaultStore, ColdDeviceStorage } from '@/store';
|
||||||
import { fetchInstance, instance } from '@/instance';
|
import { instance, instanceMetaReady } from '@/instance';
|
||||||
import { makeHotkey } from '@/scripts/hotkey';
|
import { makeHotkey } from '@/scripts/hotkey';
|
||||||
import { search } from '@/scripts/search';
|
import { search } from '@/scripts/search';
|
||||||
import { deviceKind } from '@/scripts/device-kind';
|
import { deviceKind } from '@/scripts/device-kind';
|
||||||
@ -159,7 +159,7 @@ if ($i && $i.token) {
|
|||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
fetchInstance().then(() => {
|
instanceMetaReady.then(() => {
|
||||||
localStorage.setItem('v', instance.version);
|
localStorage.setItem('v', instance.version);
|
||||||
|
|
||||||
// Init service worker
|
// Init service worker
|
||||||
|
@ -8,11 +8,11 @@ const data = localStorage.getItem('instance');
|
|||||||
|
|
||||||
// TODO: instanceをリアクティブにするかは再考の余地あり
|
// TODO: instanceをリアクティブにするかは再考の余地あり
|
||||||
|
|
||||||
export const instance: Misskey.entities.InstanceMetadata = reactive(data ? JSON.parse(data) : {
|
export const instance: Misskey.entities.InstanceMetadata = reactive(data != null ? JSON.parse(data) : {
|
||||||
// TODO: set default values
|
// TODO: set default values
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function fetchInstance() {
|
async function fetchInstance() {
|
||||||
const meta = await api('meta', {
|
const meta = await api('meta', {
|
||||||
detail: false
|
detail: false
|
||||||
});
|
});
|
||||||
@ -24,6 +24,11 @@ export async function fetchInstance() {
|
|||||||
localStorage.setItem('instance', JSON.stringify(instance));
|
localStorage.setItem('instance', JSON.stringify(instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const initialFetchPromise = fetchInstance();
|
||||||
|
export const instanceMetaReady = data != null ? Promise.resolve() : initialFetchPromise;
|
||||||
|
|
||||||
|
export const refetchInstanceMeta = fetchInstance;
|
||||||
|
|
||||||
export const emojiCategories = computed(() => {
|
export const emojiCategories = computed(() => {
|
||||||
if (instance.emojis == null) return [];
|
if (instance.emojis == null) return [];
|
||||||
const categories = new Set();
|
const categories = new Set();
|
||||||
|
@ -52,7 +52,7 @@ import FormSuspense from '@/components/form/suspense.vue';
|
|||||||
import FormSlot from '@/components/form/slot.vue';
|
import FormSlot from '@/components/form/slot.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -109,7 +109,7 @@ export default defineComponent({
|
|||||||
recaptchaSiteKey: this.recaptchaSiteKey,
|
recaptchaSiteKey: this.recaptchaSiteKey,
|
||||||
recaptchaSecretKey: this.recaptchaSecretKey,
|
recaptchaSecretKey: this.recaptchaSecretKey,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ import FormSplit from '@/components/form/split.vue';
|
|||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -129,7 +129,7 @@ export default defineComponent({
|
|||||||
smtpUser: this.smtpUser,
|
smtpUser: this.smtpUser,
|
||||||
smtpPass: this.smtpPass,
|
smtpPass: this.smtpPass,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import FormTextarea from '@/components/form/textarea.vue';
|
|||||||
import FormSuspense from '@/components/form/suspense.vue';
|
import FormSuspense from '@/components/form/suspense.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -50,7 +50,7 @@ export default defineComponent({
|
|||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
blockedHosts: this.blockedHosts.split('\n') || [],
|
blockedHosts: this.blockedHosts.split('\n') || [],
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import FormInfo from '@/components/ui/info.vue';
|
|||||||
import FormSuspense from '@/components/form/suspense.vue';
|
import FormSuspense from '@/components/form/suspense.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -72,7 +72,7 @@ export default defineComponent({
|
|||||||
discordClientId: this.discordClientId,
|
discordClientId: this.discordClientId,
|
||||||
discordClientSecret: this.discordClientSecret,
|
discordClientSecret: this.discordClientSecret,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import FormInfo from '@/components/ui/info.vue';
|
|||||||
import FormSuspense from '@/components/form/suspense.vue';
|
import FormSuspense from '@/components/form/suspense.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -72,7 +72,7 @@ export default defineComponent({
|
|||||||
githubClientId: this.githubClientId,
|
githubClientId: this.githubClientId,
|
||||||
githubClientSecret: this.githubClientSecret,
|
githubClientSecret: this.githubClientSecret,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import FormInfo from '@/components/ui/info.vue';
|
|||||||
import FormSuspense from '@/components/form/suspense.vue';
|
import FormSuspense from '@/components/form/suspense.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -72,7 +72,7 @@ export default defineComponent({
|
|||||||
twitterConsumerKey: this.twitterConsumerKey,
|
twitterConsumerKey: this.twitterConsumerKey,
|
||||||
twitterConsumerSecret: this.twitterConsumerSecret,
|
twitterConsumerSecret: this.twitterConsumerSecret,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import XGithub from './integrations.github.vue';
|
|||||||
import XDiscord from './integrations.discord.vue';
|
import XDiscord from './integrations.discord.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
|
@ -75,7 +75,7 @@ import FormSplit from '@/components/form/split.vue';
|
|||||||
import FormSection from '@/components/form/section.vue';
|
import FormSection from '@/components/form/section.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -151,7 +151,7 @@ export default defineComponent({
|
|||||||
objectStorageSetPublicRead: this.objectStorageSetPublicRead,
|
objectStorageSetPublicRead: this.objectStorageSetPublicRead,
|
||||||
objectStorageS3ForcePathStyle: this.objectStorageS3ForcePathStyle,
|
objectStorageS3ForcePathStyle: this.objectStorageS3ForcePathStyle,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import FormSection from '@/components/form/section.vue';
|
|||||||
import FormSuspense from '@/components/form/suspense.vue';
|
import FormSuspense from '@/components/form/suspense.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -49,7 +49,7 @@ export default defineComponent({
|
|||||||
save() {
|
save() {
|
||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import MkInfo from '@/components/ui/info.vue';
|
|||||||
import FormSuspense from '@/components/form/suspense.vue';
|
import FormSuspense from '@/components/form/suspense.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -65,7 +65,7 @@ export default defineComponent({
|
|||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
proxyAccountId: this.proxyAccountId,
|
proxyAccountId: this.proxyAccountId,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ import FormButton from '@/components/ui/button.vue';
|
|||||||
import XBotProtection from './bot-protection.vue';
|
import XBotProtection from './bot-protection.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -82,7 +82,7 @@ export default defineComponent({
|
|||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
summalyProxy: this.summalyProxy,
|
summalyProxy: this.summalyProxy,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ import FormSplit from '@/components/form/split.vue';
|
|||||||
import FormSuspense from '@/components/form/suspense.vue';
|
import FormSuspense from '@/components/form/suspense.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
import { fetchInstance } from '@/instance';
|
import { refetchInstanceMeta } from '@/instance';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -244,7 +244,7 @@ export default defineComponent({
|
|||||||
deeplAuthKey: this.deeplAuthKey,
|
deeplAuthKey: this.deeplAuthKey,
|
||||||
deeplIsPro: this.deeplIsPro,
|
deeplIsPro: this.deeplIsPro,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
fetchInstance();
|
refetchInstanceMeta();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
const installedThemes = ref(getThemes());
|
const installedThemes = ref(getThemes());
|
||||||
const themes = computed(() => builtinThemes.concat(installedThemes.value));
|
const themes = computed(() => builtinThemes.concat(installedThemes.value));
|
||||||
const darkThemes = computed(() => themes.value.filter(t => t.base == 'dark' || t.kind == 'dark'));
|
const darkThemes = computed(() => themes.value.filter(t => t.base === 'dark' || t.kind === 'dark'));
|
||||||
const lightThemes = computed(() => themes.value.filter(t => t.base == 'light' || t.kind == 'light'));
|
const lightThemes = computed(() => themes.value.filter(t => t.base === 'light' || t.kind === 'light'));
|
||||||
const darkTheme = ColdDeviceStorage.ref('darkTheme');
|
const darkTheme = ColdDeviceStorage.ref('darkTheme');
|
||||||
const darkThemeId = computed({
|
const darkThemeId = computed({
|
||||||
get() {
|
get() {
|
||||||
|
Loading…
Reference in New Issue
Block a user