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

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