Skip to content

Commit

Permalink
エラーが出ないのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Oct 12, 2024
1 parent 53cce07 commit 4515341
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
13 changes: 5 additions & 8 deletions packages/frontend/src/components/MkUserSetupDialog.Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,11 @@ watch(name, () => {
// 空文字列をnullにしたいので??は使うな
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
name: name.value || null,
}, undefined, null, err => {
if (err.code === 'SCREEN_NAME_CONTAINS_PROHIBITED_WORDS') {
os.alert({
type: 'error',
title: i18n.ts.screenNameContainsProhibitedWords,
text: i18n.ts.screenNameContainsProhibitedWordsDescription,
});
}
}, undefined, {
'0b3f9f6a-2f4d-4b1f-9fb4-49d3a2fd7191': {
title: i18n.ts.screenNameContainsProhibitedWords,
text: i18n.ts.screenNameContainsProhibitedWordsDescription,
},
});
});

Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const apiWithDialog = (<E extends keyof Misskey.Endpoints = keyof Misskey
endpoint: E,
data: P = {} as any,
token?: string | null | undefined,
customErrors?: Record<string, { title?: string; text: string; }>,
) => {
const promise = misskeyApi(endpoint, data, token);
promiseDialog(promise, null, async (err) => {
Expand Down Expand Up @@ -77,6 +78,9 @@ export const apiWithDialog = (<E extends keyof Misskey.Endpoints = keyof Misskey
} else if (err.message.startsWith('Unexpected token')) {
title = i18n.ts.gotInvalidResponseError;
text = i18n.ts.gotInvalidResponseErrorDescription;
} else if (customErrors && customErrors[err.id]) {
title = customErrors[err.id].title;
text = customErrors[err.id].text;
}
alert({
type: 'error',
Expand Down
13 changes: 5 additions & 8 deletions packages/frontend/src/pages/settings/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,11 @@ function save() {
lang: profile.lang || null,
isBot: !!profile.isBot,
isCat: !!profile.isCat,
}, undefined, null, err => {
if (err.code === 'SCREEN_NAME_CONTAINS_PROHIBITED_WORDS') {
os.alert({
type: 'error',
title: i18n.ts.screenNameContainsProhibitedWords,
text: i18n.ts.screenNameContainsProhibitedWordsDescription,
});
}
}, undefined, {
'0b3f9f6a-2f4d-4b1f-9fb4-49d3a2fd7191': {
title: i18n.ts.screenNameContainsProhibitedWords,
text: i18n.ts.screenNameContainsProhibitedWordsDescription,
},
});
globalEvents.emit('requestClearPageCache');
claimAchievement('profileFilled');
Expand Down
11 changes: 4 additions & 7 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,10 @@ export function getNoteMenu(props: {
function togglePin(pin: boolean): void {
os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', {
noteId: appearNote.id,
}, undefined, null, res => {
if (res.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
os.alert({
type: 'error',
text: i18n.ts.pinLimitExceeded,
});
}
}, undefined, {
'72dab508-c64d-498f-8740-a8eec1ba385a': {
text: i18n.ts.pinLimitExceeded,
},
});
}

Expand Down

0 comments on commit 4515341

Please sign in to comment.