mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-09 19:23:08 +02:00
refactor
This commit is contained in:
parent
d69f7baaf5
commit
94d4f8271e
15 changed files with 34 additions and 29 deletions
|
@ -29,7 +29,7 @@ import { stream } from '@/stream';
|
|||
import * as sound from '@/scripts/sound';
|
||||
import { $i, refreshAccount, login, updateAccount, signout } from '@/account';
|
||||
import { defaultStore, ColdDeviceStorage } from '@/store';
|
||||
import { fetchInstance, instance } from '@/instance';
|
||||
import { instance, instanceMetaReady } from '@/instance';
|
||||
import { makeHotkey } from '@/scripts/hotkey';
|
||||
import { search } from '@/scripts/search';
|
||||
import { deviceKind } from '@/scripts/device-kind';
|
||||
|
@ -159,7 +159,7 @@ if ($i && $i.token) {
|
|||
}
|
||||
//#endregion
|
||||
|
||||
fetchInstance().then(() => {
|
||||
instanceMetaReady.then(() => {
|
||||
localStorage.setItem('v', instance.version);
|
||||
|
||||
// Init service worker
|
||||
|
|
|
@ -8,11 +8,11 @@ const data = localStorage.getItem('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
|
||||
});
|
||||
|
||||
export async function fetchInstance() {
|
||||
async function fetchInstance() {
|
||||
const meta = await api('meta', {
|
||||
detail: false
|
||||
});
|
||||
|
@ -24,6 +24,11 @@ export async function fetchInstance() {
|
|||
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(() => {
|
||||
if (instance.emojis == null) return [];
|
||||
const categories = new Set();
|
||||
|
|
|
@ -52,7 +52,7 @@ import FormSuspense from '@/components/form/suspense.vue';
|
|||
import FormSlot from '@/components/form/slot.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -109,7 +109,7 @@ export default defineComponent({
|
|||
recaptchaSiteKey: this.recaptchaSiteKey,
|
||||
recaptchaSecretKey: this.recaptchaSecretKey,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ import FormSplit from '@/components/form/split.vue';
|
|||
import FormSection from '@/components/form/section.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -129,7 +129,7 @@ export default defineComponent({
|
|||
smtpUser: this.smtpUser,
|
||||
smtpPass: this.smtpPass,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import FormTextarea from '@/components/form/textarea.vue';
|
|||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -50,7 +50,7 @@ export default defineComponent({
|
|||
os.apiWithDialog('admin/update-meta', {
|
||||
blockedHosts: this.blockedHosts.split('\n') || [],
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import FormInfo from '@/components/ui/info.vue';
|
|||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -72,7 +72,7 @@ export default defineComponent({
|
|||
discordClientId: this.discordClientId,
|
||||
discordClientSecret: this.discordClientSecret,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import FormInfo from '@/components/ui/info.vue';
|
|||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -72,7 +72,7 @@ export default defineComponent({
|
|||
githubClientId: this.githubClientId,
|
||||
githubClientSecret: this.githubClientSecret,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import FormInfo from '@/components/ui/info.vue';
|
|||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -72,7 +72,7 @@ export default defineComponent({
|
|||
twitterConsumerKey: this.twitterConsumerKey,
|
||||
twitterConsumerSecret: this.twitterConsumerSecret,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import XGithub from './integrations.github.vue';
|
|||
import XDiscord from './integrations.discord.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
|
|
@ -75,7 +75,7 @@ import FormSplit from '@/components/form/split.vue';
|
|||
import FormSection from '@/components/form/section.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -151,7 +151,7 @@ export default defineComponent({
|
|||
objectStorageSetPublicRead: this.objectStorageSetPublicRead,
|
||||
objectStorageS3ForcePathStyle: this.objectStorageS3ForcePathStyle,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import FormSection from '@/components/form/section.vue';
|
|||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -49,7 +49,7 @@ export default defineComponent({
|
|||
save() {
|
||||
os.apiWithDialog('admin/update-meta', {
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import MkInfo from '@/components/ui/info.vue';
|
|||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -65,7 +65,7 @@ export default defineComponent({
|
|||
os.apiWithDialog('admin/update-meta', {
|
||||
proxyAccountId: this.proxyAccountId,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import FormButton from '@/components/ui/button.vue';
|
|||
import XBotProtection from './bot-protection.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -82,7 +82,7 @@ export default defineComponent({
|
|||
os.apiWithDialog('admin/update-meta', {
|
||||
summalyProxy: this.summalyProxy,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ import FormSplit from '@/components/form/split.vue';
|
|||
import FormSuspense from '@/components/form/suspense.vue';
|
||||
import * as os from '@/os';
|
||||
import * as symbols from '@/symbols';
|
||||
import { fetchInstance } from '@/instance';
|
||||
import { refetchInstanceMeta } from '@/instance';
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
|
@ -244,7 +244,7 @@ export default defineComponent({
|
|||
deeplAuthKey: this.deeplAuthKey,
|
||||
deeplIsPro: this.deeplIsPro,
|
||||
}).then(() => {
|
||||
fetchInstance();
|
||||
refetchInstanceMeta();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ export default defineComponent({
|
|||
|
||||
const installedThemes = ref(getThemes());
|
||||
const themes = computed(() => builtinThemes.concat(installedThemes.value));
|
||||
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 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 darkTheme = ColdDeviceStorage.ref('darkTheme');
|
||||
const darkThemeId = computed({
|
||||
get() {
|
||||
|
|
Loading…
Reference in a new issue