Skip to content

Commit

Permalink
fix(frontend): オンボーディング完了後にアカウントのキャッシュが更新されない問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Aug 26, 2024
1 parent 60490a4 commit 8acaf65
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5085,8 +5085,8 @@ export interface Locale extends ILocale {
*/
"createdAntennas": string;
/**
* これ以上このクリップにノートを追加できません。
*/
* これ以上このクリップにノートを追加できません。
*/
"clipNoteLimitExceeded": string;
/**
* チュートリアルをスキップできないようにする
Expand Down
12 changes: 8 additions & 4 deletions packages/frontend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ export async function common(createVue: () => App<Element>) {
!location.pathname.startsWith('/onboarding') &&
!location.pathname.startsWith('/signup-complete')
) {
const param = new URLSearchParams();
param.set('redirected_from', location.pathname + location.search + location.hash);
location.replace('/onboarding?' + param.toString());
return;
await refreshAccount();

if ($i && !$i.achievements.map((v) => v.name).includes('tutorialCompleted')) {
const param = new URLSearchParams();
param.set('redirected_from', location.pathname + location.search + location.hash);
location.replace('/onboarding?' + param.toString());
return;
}
}

const fetchInstanceMetaPromise = fetchInstance();
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/components/HanaHanaModeSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<script setup lang="ts">
import { ref, computed } from 'vue';
import { signinRequired } from '@/account.js';
import { signinRequired, updateAccount } from '@/account.js';
import { i18n } from '@/i18n.js';
import { globalEvents } from '@/events.js';
import { claimAchievement } from '@/scripts/achievements.js';
Expand Down Expand Up @@ -92,6 +92,7 @@ async function setMode() {
os.apiWithDialog('i/update', {
isInHanaMode,
});
updateAccount({ isInHanaMode });
}
emit('set');
onceSet.value = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import FormSlot from '@/components/form/slot.vue';
import MkInfo from '@/components/MkInfo.vue';
import { selectFile } from '@/scripts/select-file.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';

const $i = signinRequired();
Expand All @@ -53,6 +53,7 @@ watch(name, () => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
name: name.value || null,
});
updateAccount({ name: name.value });
});

watch(description, () => {
Expand All @@ -61,6 +62,7 @@ watch(description, () => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
description: description.value || null,
});
updateAccount({ description: description.value });
});

function setAvatar(ev: MouseEvent) {
Expand All @@ -83,8 +85,7 @@ function setAvatar(ev: MouseEvent) {
const i = await os.apiWithDialog('i/update', {
avatarId: originalOrCropped.id,
});
$i.avatarId = i.avatarId;
$i.avatarUrl = i.avatarUrl;
updateAccount({ avatarId: i.avatarId, avatarUrl: i.avatarUrl });
});
}

Expand Down
6 changes: 5 additions & 1 deletion packages/frontend/src/scripts/achievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i } from '@/account.js';
import { $i, refreshAccount } from '@/account.js';

export const ACHIEVEMENT_TYPES = [
'notes1',
Expand Down Expand Up @@ -506,6 +506,10 @@ export async function claimAchievement(type: typeof ACHIEVEMENT_TYPES[number]) {
await new Promise(resolve => setTimeout(resolve, (claimingQueue.size - 1) * 500));
window.setTimeout(() => {
claimingQueue.delete(type);

if (claimingQueue.size === 0) {
refreshAccount();
}
}, 500);
misskeyApi('i/claim-achievement', { name: type });
}
Expand Down

0 comments on commit 8acaf65

Please sign in to comment.