Actually fix standalone mode

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-08-19 21:51:43 +02:00
parent 3ecffaef08
commit 614168d079
8 changed files with 14 additions and 14 deletions

View file

@ -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",

View file

@ -20,7 +20,7 @@ const createApp = (params: CreateApplicationParams, baseURL?: string) =>
(dispatch: React.Dispatch<AnyAction>) => {
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<string, string>;

View file

@ -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));

View file

@ -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) {

View file

@ -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;

View file

@ -35,7 +35,7 @@ const ReducerRecord = ImmutableRecord({
tokens: ImmutableMap<string, Token>(),
users: ImmutableMap<string, AuthUser>(),
me: null as string | null,
client: new PlApiClient(backendUrl) as any as PlApiClient,
client: new PlApiClient(backendUrl),
});
type AuthUser = ReturnType<typeof AuthUserRecord>;
@ -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,

View file

@ -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;

View file

@ -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"