Skip to content

Commit 58c7426

Browse files
committed
fix(web): early abort sendMessage and fix invalid auth
1 parent 719af6e commit 58c7426

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@dvcol/tmdb-http-client": "^1.2.3",
5757
"@dvcol/trakt-http-client": "^1.4.5",
5858
"@dvcol/tvdb-http-client": "^1.1.3",
59-
"@dvcol/web-extension-utils": "^3.3.0",
59+
"@dvcol/web-extension-utils": "^3.3.2",
6060
"@vue/devtools": "^7.0.15",
6161
"iso-3166-2": "^1.0.0",
6262
"naive-ui": "^2.38.1",

pnpm-lock.yaml

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/browser/browser-message.utils.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { ApiUnavailableError } from '@dvcol/web-extension-utils/chrome/error';
22
import { onMessageEvent, sendMessageEvent } from '@dvcol/web-extension-utils/chrome/message';
33

4+
import { chromeRuntimeId } from '@dvcol/web-extension-utils/chrome/runtime';
5+
46
import type { ChromeMessage, ChromeMessageListener, ChromeMessageOptions, ChromeResponsePayload } from '@dvcol/web-extension-utils/chrome/models';
57

68
import type { MessagePayload, MessageTypes } from '~/models/message/message-type.model';
@@ -22,6 +24,7 @@ export const sendMessage = async <
2224
message: ChromeMessage<T, P>,
2325
options?: ChromeMessageOptions,
2426
) => {
27+
if (!chromeRuntimeId) return console.warn('Chrome runtime ID not available');
2528
try {
2629
return await sendMessageEvent<T, P, R>(message, options);
2730
} catch (error) {

src/utils/i18n.utils.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { chromeI18n, useI18nTranslate } from '@dvcol/web-extension-utils/chrome/i18n';
2-
31
import type { Locale, Locales } from '~/models/i18n.model';
42

53
import { useI18nStore } from '~/stores/i18n.store';
64
import { useRouterStore } from '~/stores/router.store';
5+
import { chromeI18n, useI18nTranslate } from '~/utils/browser/browser-i18n.utils';
76

87
export const initLocalI18n = () => {
98
const store = useI18nStore();

src/web/init-services.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ export const initServices = async () => {
4646
const restoredSettings = await syncRestoreUser();
4747
const restoredAuth = await syncRestoreAuth(restoredSettings?.user?.username);
4848

49-
await TraktService.importAuthentication(restoredAuth);
49+
try {
50+
await TraktService.importAuthentication(restoredAuth);
51+
} catch (error) {
52+
Logger.error('Failed to import authentication', error);
53+
await TraktService.logout();
54+
}
5055

5156
TraktService.listen();
5257

0 commit comments

Comments
 (0)