mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 10:12:11 +00:00
[chore] Settings refactor fix 2 (#1357)
* fix emoji query tagging * fix proxy url for gts instance * fix: don't flash callback error on authorize flow
This commit is contained in:
parent
13e3aaaed1
commit
747683ba54
|
@ -48,7 +48,7 @@ skulk({
|
||||||
},
|
},
|
||||||
servers: {
|
servers: {
|
||||||
express: {
|
express: {
|
||||||
proxy: "http://localhost:8081",
|
proxy: "http://127.0.0.1:8081",
|
||||||
assets: "/assets"
|
assets: "/assets"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -44,7 +44,7 @@ function CategorySelect({ field, children }) {
|
||||||
isLoading,
|
isLoading,
|
||||||
isSuccess,
|
isSuccess,
|
||||||
error
|
error
|
||||||
} = query.useGetAllEmojiQuery({ filter: "domain:local" });
|
} = query.useListEmojiQuery({ filter: "domain:local" });
|
||||||
|
|
||||||
const emojiByCategory = useEmojiByCategory(emoji);
|
const emojiByCategory = useEmojiByCategory(emoji);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ module.exports = function EmojiOverview({ baseUrl }) {
|
||||||
data: emoji = [],
|
data: emoji = [],
|
||||||
isLoading,
|
isLoading,
|
||||||
error
|
error
|
||||||
} = query.useGetAllEmojiQuery({ filter: "domain:local" });
|
} = query.useListEmojiQuery({ filter: "domain:local" });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -28,7 +28,7 @@ const shortcodeRegex = /^[a-z0-9_]+$/;
|
||||||
module.exports = function useShortcode() {
|
module.exports = function useShortcode() {
|
||||||
const {
|
const {
|
||||||
data: emoji = []
|
data: emoji = []
|
||||||
} = query.useGetAllEmojiQuery({ filter: "domain:local" });
|
} = query.useListEmojiQuery({ filter: "domain:local" });
|
||||||
|
|
||||||
const emojiCodes = React.useMemo(() => {
|
const emojiCodes = React.useMemo(() => {
|
||||||
return new Set(emoji.map((e) => e.shortcode));
|
return new Set(emoji.map((e) => e.shortcode));
|
||||||
|
|
|
@ -31,7 +31,7 @@ module.exports = function RemoteEmoji() {
|
||||||
data: emoji = [],
|
data: emoji = [],
|
||||||
isLoading,
|
isLoading,
|
||||||
error
|
error
|
||||||
} = query.useGetAllEmojiQuery({ filter: "domain:local" });
|
} = query.useListEmojiQuery({ filter: "domain:local" });
|
||||||
|
|
||||||
const emojiCodes = React.useMemo(() => {
|
const emojiCodes = React.useMemo(() => {
|
||||||
return new Set(emoji.map((e) => e.shortcode));
|
return new Set(emoji.map((e) => e.shortcode));
|
||||||
|
|
|
@ -28,17 +28,18 @@ const Loading = require("../loading");
|
||||||
const { Error } = require("../error");
|
const { Error } = require("../error");
|
||||||
|
|
||||||
module.exports = function Authorization({ App }) {
|
module.exports = function Authorization({ App }) {
|
||||||
const loginState = Redux.useSelector((state) => state.oauth.loginState);
|
const { loginState, expectingRedirect } = Redux.useSelector((state) => state.oauth);
|
||||||
const [hasStoredLogin] = React.useState(loginState != "none" && loginState != "logout");
|
|
||||||
|
|
||||||
const { isLoading, isSuccess, data: account, error } = query.useVerifyCredentialsQuery(undefined, {
|
const { isLoading, isSuccess, data: account, error } = query.useVerifyCredentialsQuery(undefined, {
|
||||||
skip: loginState == "none" || loginState == "logout"
|
skip: loginState == "none" || loginState == "logout" || expectingRedirect
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("skip verify:", loginState, expectingRedirect);
|
||||||
|
|
||||||
let showLogin = true;
|
let showLogin = true;
|
||||||
let content = null;
|
let content = null;
|
||||||
|
|
||||||
if (isLoading && hasStoredLogin) {
|
if (isLoading) {
|
||||||
showLogin = false;
|
showLogin = false;
|
||||||
|
|
||||||
let loadingInfo;
|
let loadingInfo;
|
||||||
|
|
|
@ -23,7 +23,7 @@ const Promise = require("bluebird");
|
||||||
const { unwrapRes } = require("../lib");
|
const { unwrapRes } = require("../lib");
|
||||||
|
|
||||||
module.exports = (build) => ({
|
module.exports = (build) => ({
|
||||||
getAllEmoji: build.query({
|
listEmoji: build.query({
|
||||||
query: (params = {}) => ({
|
query: (params = {}) => ({
|
||||||
url: "/api/v1/admin/custom_emojis",
|
url: "/api/v1/admin/custom_emojis",
|
||||||
params: {
|
params: {
|
||||||
|
@ -33,15 +33,15 @@ module.exports = (build) => ({
|
||||||
}),
|
}),
|
||||||
providesTags: (res) =>
|
providesTags: (res) =>
|
||||||
res
|
res
|
||||||
? [...res.map((emoji) => ({ type: "Emojis", id: emoji.id })), { type: "Emojis", id: "LIST" }]
|
? [...res.map((emoji) => ({ type: "Emoji", id: emoji.id })), { type: "Emoji", id: "LIST" }]
|
||||||
: [{ type: "Emojis", id: "LIST" }]
|
: [{ type: "Emoji", id: "LIST" }]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getEmoji: build.query({
|
getEmoji: build.query({
|
||||||
query: (id) => ({
|
query: (id) => ({
|
||||||
url: `/api/v1/admin/custom_emojis/${id}`
|
url: `/api/v1/admin/custom_emojis/${id}`
|
||||||
}),
|
}),
|
||||||
providesTags: (res, error, id) => [{ type: "Emojis", id }]
|
providesTags: (res, error, id) => [{ type: "Emoji", id }]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
addEmoji: build.mutation({
|
addEmoji: build.mutation({
|
||||||
|
@ -56,8 +56,8 @@ module.exports = (build) => ({
|
||||||
},
|
},
|
||||||
invalidatesTags: (res) =>
|
invalidatesTags: (res) =>
|
||||||
res
|
res
|
||||||
? [{ type: "Emojis", id: "LIST" }, { type: "Emojis", id: res.id }]
|
? [{ type: "Emoji", id: "LIST" }, { type: "Emoji", id: res.id }]
|
||||||
: [{ type: "Emojis", id: "LIST" }]
|
: [{ type: "Emoji", id: "LIST" }]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
editEmoji: build.mutation({
|
editEmoji: build.mutation({
|
||||||
|
@ -74,8 +74,8 @@ module.exports = (build) => ({
|
||||||
},
|
},
|
||||||
invalidatesTags: (res) =>
|
invalidatesTags: (res) =>
|
||||||
res
|
res
|
||||||
? [{ type: "Emojis", id: "LIST" }, { type: "Emojis", id: res.id }]
|
? [{ type: "Emoji", id: "LIST" }, { type: "Emoji", id: res.id }]
|
||||||
: [{ type: "Emojis", id: "LIST" }]
|
: [{ type: "Emoji", id: "LIST" }]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
deleteEmoji: build.mutation({
|
deleteEmoji: build.mutation({
|
||||||
|
@ -83,7 +83,7 @@ module.exports = (build) => ({
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
url: `/api/v1/admin/custom_emojis/${id}`
|
url: `/api/v1/admin/custom_emojis/${id}`
|
||||||
}),
|
}),
|
||||||
invalidatesTags: (res, error, id) => [{ type: "Emojis", id }]
|
invalidatesTags: (res, error, id) => [{ type: "Emoji", id }]
|
||||||
}),
|
}),
|
||||||
|
|
||||||
searchStatusForEmoji: build.mutation({
|
searchStatusForEmoji: build.mutation({
|
||||||
|
@ -167,7 +167,7 @@ module.exports = (build) => ({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
invalidatesTags: () => [{ type: "Emojis", id: "LIST" }]
|
invalidatesTags: () => [{ type: "Emoji", id: "LIST" }]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ function instanceBasedQuery(args, api, extraOptions) {
|
||||||
module.exports = createApi({
|
module.exports = createApi({
|
||||||
reducerPath: "api",
|
reducerPath: "api",
|
||||||
baseQuery: instanceBasedQuery,
|
baseQuery: instanceBasedQuery,
|
||||||
tagTypes: ["Auth"],
|
tagTypes: ["Auth", "Emoji"],
|
||||||
endpoints: (build) => ({
|
endpoints: (build) => ({
|
||||||
instance: build.query({
|
instance: build.query({
|
||||||
query: () => ({
|
query: () => ({
|
||||||
|
|
|
@ -121,10 +121,11 @@ const endpoints = (build) => ({
|
||||||
}).then(unwrapRes).then((app) => {
|
}).then(unwrapRes).then((app) => {
|
||||||
app.scopes = formData.scopes;
|
app.scopes = formData.scopes;
|
||||||
|
|
||||||
api.dispatch(oauth.setInstance({
|
api.dispatch(oauth.authorize({
|
||||||
instance: instance,
|
instance: instance,
|
||||||
registration: app,
|
registration: app,
|
||||||
loginState: "callback"
|
loginState: "callback",
|
||||||
|
expectingRedirect: true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
|
|
|
@ -32,6 +32,7 @@ const {
|
||||||
} = require("redux-persist");
|
} = require("redux-persist");
|
||||||
|
|
||||||
const query = require("../lib/query/base");
|
const query = require("../lib/query/base");
|
||||||
|
const { Promise } = require("bluebird");
|
||||||
|
|
||||||
const combinedReducers = combineReducers({
|
const combinedReducers = combineReducers({
|
||||||
oauth: require("./oauth").reducer,
|
oauth: require("./oauth").reducer,
|
||||||
|
@ -43,6 +44,14 @@ const persistedReducer = persistReducer({
|
||||||
storage: require("redux-persist/lib/storage").default,
|
storage: require("redux-persist/lib/storage").default,
|
||||||
stateReconciler: require("redux-persist/lib/stateReconciler/autoMergeLevel1").default,
|
stateReconciler: require("redux-persist/lib/stateReconciler/autoMergeLevel1").default,
|
||||||
whitelist: ["oauth"],
|
whitelist: ["oauth"],
|
||||||
|
migrate: (state) => {
|
||||||
|
return Promise.try(() => {
|
||||||
|
if (state?.oauth != undefined) {
|
||||||
|
state.oauth.expectingRedirect = false;
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
});
|
||||||
|
}
|
||||||
}, combinedReducers);
|
}, combinedReducers);
|
||||||
|
|
||||||
const store = configureStore({
|
const store = configureStore({
|
||||||
|
|
|
@ -23,17 +23,12 @@ const { createSlice } = require("@reduxjs/toolkit");
|
||||||
module.exports = createSlice({
|
module.exports = createSlice({
|
||||||
name: "oauth",
|
name: "oauth",
|
||||||
initialState: {
|
initialState: {
|
||||||
loginState: 'none'
|
loginState: 'none',
|
||||||
|
expectingRedirect: false
|
||||||
},
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
setInstance: (state, { payload }) => {
|
authorize: (state, { payload }) => {
|
||||||
return {
|
return payload; // overrides state
|
||||||
...state,
|
|
||||||
...payload /* overrides instance, registration keys */
|
|
||||||
};
|
|
||||||
},
|
|
||||||
authorize: (state) => {
|
|
||||||
state.loginState = "callback";
|
|
||||||
},
|
},
|
||||||
setToken: (state, { payload }) => {
|
setToken: (state, { payload }) => {
|
||||||
state.token = `${payload.token_type} ${payload.access_token}`;
|
state.token = `${payload.token_type} ${payload.access_token}`;
|
||||||
|
|
Loading…
Reference in a new issue