チュートリアル完了後にアカウントのキャッシュが更新されない問題を修正

This commit is contained in:
kakkokari-gtyih 2024-08-26 18:15:34 +09:00
parent 79812e4ccb
commit 63b7795007
3 changed files with 17 additions and 8 deletions

View File

@ -129,10 +129,14 @@ export async function common(createVue: () => App<Element>) {
!location.pathname.startsWith('/onboarding') && !location.pathname.startsWith('/onboarding') &&
!location.pathname.startsWith('/signup-complete') !location.pathname.startsWith('/signup-complete')
) { ) {
const param = new URLSearchParams(); await refreshAccount();
param.set('redirected_from', location.pathname + location.search + location.hash);
location.replace('/onboarding?' + param.toString()); if ($i && !$i.achievements.map((v) => v.name).includes('tutorialCompleted')) {
return; const param = new URLSearchParams();
param.set('redirected_from', location.pathname + location.search + location.hash);
location.replace('/onboarding?' + param.toString());
return;
}
} }
const fetchInstanceMetaPromise = fetchInstance(); const fetchInstanceMetaPromise = fetchInstance();

View File

@ -39,7 +39,7 @@ import FormSlot from '@/components/form/slot.vue';
import MkInfo from '@/components/MkInfo.vue'; import MkInfo from '@/components/MkInfo.vue';
import { selectFile } from '@/scripts/select-file.js'; import { selectFile } from '@/scripts/select-file.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { signinRequired } from '@/account.js'; import { signinRequired, updateAccount } from '@/account.js';
import type { TutorialPageCommonExpose } from '@/components/MkTutorial.vue'; import type { TutorialPageCommonExpose } from '@/components/MkTutorial.vue';
const $i = signinRequired(); const $i = signinRequired();
@ -53,6 +53,7 @@ watch(name, () => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
name: name.value || null, name: name.value || null,
}); });
updateAccount({ name: name.value });
}); });
watch(description, () => { watch(description, () => {
@ -61,6 +62,7 @@ watch(description, () => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
description: description.value || null, description: description.value || null,
}); });
updateAccount({ description: description.value });
}); });
function setAvatar(ev: MouseEvent) { function setAvatar(ev: MouseEvent) {
@ -83,8 +85,7 @@ function setAvatar(ev: MouseEvent) {
const i = await os.apiWithDialog('i/update', { const i = await os.apiWithDialog('i/update', {
avatarId: originalOrCropped.id, avatarId: originalOrCropped.id,
}); });
$i.avatarId = i.avatarId; updateAccount({ avatarId: i.avatarId, avatarUrl: i.avatarUrl });
$i.avatarUrl = i.avatarUrl;
}); });
} }

View File

@ -4,7 +4,7 @@
*/ */
import { misskeyApi } from '@/scripts/misskey-api.js'; import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i } from '@/account.js'; import { $i, refreshAccount } from '@/account.js';
export const ACHIEVEMENT_TYPES = [ export const ACHIEVEMENT_TYPES = [
'notes1', 'notes1',
@ -500,6 +500,10 @@ export async function claimAchievement(type: typeof ACHIEVEMENT_TYPES[number]) {
await new Promise(resolve => setTimeout(resolve, (claimingQueue.size - 1) * 500)); await new Promise(resolve => setTimeout(resolve, (claimingQueue.size - 1) * 500));
window.setTimeout(() => { window.setTimeout(() => {
claimingQueue.delete(type); claimingQueue.delete(type);
if (claimingQueue.size === 0) {
refreshAccount();
}
}, 500); }, 500);
misskeyApi('i/claim-achievement', { name: type }); misskeyApi('i/claim-achievement', { name: type });
} }