Revert "refactor"

This reverts commit 94d4f8271e.
This commit is contained in:
syuilo 2022-03-01 03:51:31 +09:00
parent a626c69547
commit 645dbebd86
15 changed files with 29 additions and 34 deletions

View File

@ -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 { instance, instanceMetaReady } from '@/instance'; import { fetchInstance, instance } 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
instanceMetaReady.then(() => { fetchInstance().then(() => {
localStorage.setItem('v', instance.version); localStorage.setItem('v', instance.version);
// Init service worker // Init service worker

View File

@ -8,11 +8,11 @@ const data = localStorage.getItem('instance');
// TODO: instanceをリアクティブにするかは再考の余地あり // TODO: instanceをリアクティブにするかは再考の余地あり
export const instance: Misskey.entities.InstanceMetadata = reactive(data != null ? JSON.parse(data) : { export const instance: Misskey.entities.InstanceMetadata = reactive(data ? JSON.parse(data) : {
// TODO: set default values // TODO: set default values
}); });
async function fetchInstance() { export async function fetchInstance() {
const meta = await api('meta', { const meta = await api('meta', {
detail: false detail: false
}); });
@ -24,11 +24,6 @@ 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();

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } from '@/instance';
export default defineComponent({ export default defineComponent({
components: { components: {

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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 { refetchInstanceMeta } from '@/instance'; import { fetchInstance } 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(() => {
refetchInstanceMeta(); fetchInstance();
}); });
} }
} }

View File

@ -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() {