From 614168d079144e32502050bf910de39e119c9720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Mon, 19 Aug 2024 21:51:43 +0200 Subject: [PATCH] Actually fix standalone mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- package.json | 2 +- src/actions/apps.ts | 2 +- src/actions/auth.ts | 4 ++-- src/actions/external-auth.ts | 2 +- src/actions/oauth.ts | 4 ++-- src/reducers/auth.ts | 4 ++-- src/reducers/meta.ts | 2 +- yarn.lock | 8 ++++---- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 4385cfe25..5bda1cbe2 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "multiselect-react-dropdown": "^2.0.25", "object-to-formdata": "^4.5.1", "path-browserify": "^1.0.1", - "pl-api": "^0.0.8", + "pl-api": "^0.0.9", "postcss": "^8.4.29", "process": "^0.11.10", "punycode": "^2.1.1", diff --git a/src/actions/apps.ts b/src/actions/apps.ts index 26f08f984..3e2b36c05 100644 --- a/src/actions/apps.ts +++ b/src/actions/apps.ts @@ -20,7 +20,7 @@ const createApp = (params: CreateApplicationParams, baseURL?: string) => (dispatch: React.Dispatch) => { dispatch({ type: APP_CREATE_REQUEST, params }); - const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '', undefined, { fetchInstance: false }); + const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || ''); return client.apps.createApplication(params).then((app) => { dispatch({ type: APP_CREATE_SUCCESS, params, app }); return app as Record; diff --git a/src/actions/auth.ts b/src/actions/auth.ts index b4df7249e..d6b4d2815 100644 --- a/src/actions/auth.ts +++ b/src/actions/auth.ts @@ -128,7 +128,7 @@ const otpVerify = (code: string, mfa_token: string) => const state = getState(); const app = state.auth.app; const baseUrl = parseBaseURL(state.me) || BuildConfig.BACKEND_URL; - const client = new PlApiClient(baseUrl, undefined, { fetchInstance: false }); + const client = new PlApiClient(baseUrl); return client.oauth.mfaChallenge({ client_id: app?.client_id!, client_secret: app?.client_secret!, @@ -146,7 +146,7 @@ const verifyCredentials = (token: string, accountUrl?: string) => dispatch({ type: VERIFY_CREDENTIALS_REQUEST, token }); - const client = new PlApiClient(baseURL, token, { fetchInstance: false }); + const client = new PlApiClient(baseURL, token); return client.settings.verifyCredentials().then((account) => { dispatch(importFetchedAccount(account)); diff --git a/src/actions/external-auth.ts b/src/actions/external-auth.ts index 7fe812687..b14cfc042 100644 --- a/src/actions/external-auth.ts +++ b/src/actions/external-auth.ts @@ -19,7 +19,7 @@ import { getInstanceScopes } from 'soapbox/utils/scopes'; import type { AppDispatch } from 'soapbox/store'; const fetchExternalInstance = (baseURL: string) => - (new PlApiClient(baseURL, undefined, { fetchInstance: false })).instance.getInstance() + (new PlApiClient(baseURL)).instance.getInstance() .then(instance => instance) .catch(error => { if (error.response?.status === 401) { diff --git a/src/actions/oauth.ts b/src/actions/oauth.ts index 097ebe3ab..cffcd2446 100644 --- a/src/actions/oauth.ts +++ b/src/actions/oauth.ts @@ -24,7 +24,7 @@ const OAUTH_TOKEN_REVOKE_FAIL = 'OAUTH_TOKEN_REVOKE_FAIL' as const; const obtainOAuthToken = (params: GetTokenParams, baseURL?: string) => (dispatch: AppDispatch) => { dispatch({ type: OAUTH_TOKEN_CREATE_REQUEST, params }); - const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || '', undefined, { fetchInstance: false }); + const client = new PlApiClient(baseURL || BuildConfig.BACKEND_URL || ''); return client.oauth.getToken(params).then((token) => { dispatch({ type: OAUTH_TOKEN_CREATE_SUCCESS, params, token }); @@ -39,7 +39,7 @@ const revokeOAuthToken = (params: RevokeTokenParams) => (dispatch: AppDispatch, getState: () => RootState) => { dispatch({ type: OAUTH_TOKEN_REVOKE_REQUEST, params }); const baseURL = getBaseURL(getState()); - const client = new PlApiClient(baseURL || '', undefined, { fetchInstance: false }); + const client = new PlApiClient(baseURL || ''); return client.oauth.revokeToken(params).then((data) => { dispatch({ type: OAUTH_TOKEN_REVOKE_SUCCESS, params, data }); return data; diff --git a/src/reducers/auth.ts b/src/reducers/auth.ts index 6e2736501..58768b697 100644 --- a/src/reducers/auth.ts +++ b/src/reducers/auth.ts @@ -35,7 +35,7 @@ const ReducerRecord = ImmutableRecord({ tokens: ImmutableMap(), users: ImmutableMap(), me: null as string | null, - client: new PlApiClient(backendUrl) as any as PlApiClient, + client: new PlApiClient(backendUrl), }); type AuthUser = ReturnType; @@ -60,7 +60,7 @@ const getLocalState = () => { if (!state) return undefined; return ReducerRecord({ - app: applicationSchema.parse(state.app), + app: state.app && applicationSchema.parse(state.app), tokens: ImmutableMap(Object.entries(state.tokens).map(([key, value]) => [key, tokenSchema.parse(value)])), users: ImmutableMap(Object.entries(state.users).map(([key, value]) => [key, AuthUserRecord(value as any)])), me: state.me, diff --git a/src/reducers/meta.ts b/src/reducers/meta.ts index a804423b9..bc13ec613 100644 --- a/src/reducers/meta.ts +++ b/src/reducers/meta.ts @@ -13,7 +13,7 @@ const ReducerRecord = ImmutableRecord({ const meta = (state = ReducerRecord(), action: InstanceAction | SwAction) => { switch (action.type) { case INSTANCE_FETCH_FAIL: - if (action.error?.status === 404) { + if (action.error?.response?.status === 404) { return state.set('instance_fetch_failed', true); } return state; diff --git a/yarn.lock b/yarn.lock index 03c9f4026..f7a91c3c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8390,10 +8390,10 @@ pkg-types@^1.0.3: mlly "^1.2.0" pathe "^1.1.0" -pl-api@^0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.8.tgz#8ccf422da7116fdf93e6d642b59e44e8ee7b978b" - integrity sha512-OJs0S4Z8bIgXJj/2U+BKX0hCyBnOcTn2I2IwRMfVXe7a+KetiF/loO4CslXh30d+0qN/vyYKg4X2/9jzJ56sgQ== +pl-api@^0.0.9: + version "0.0.9" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.9.tgz#8e5c1d205e44f6e7fa332b14cafe49c67c00175e" + integrity sha512-oJwYdkdpvuXwVPWYBWcbWbwIg2zm+vNBxeni5usfH2RI4Co+WiCkuCnhM7pxyB0YnqvgCtAnFJY4O9YUT47xRg== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3"