redux fixes

This commit is contained in:
f0x 2023-01-13 23:56:45 +00:00
parent 873fd22cfb
commit 9f8603de31
3 changed files with 8 additions and 9 deletions

View file

@ -186,7 +186,6 @@ module.exports = {
},
oauth: require("./oauth")(submoduleArgs),
user: require("./user")(submoduleArgs),
admin: require("./admin")(submoduleArgs),
apiCall,
convertToForm,
getChanges

View file

@ -24,7 +24,6 @@ const { OAUTHError, AuthenticationError } = require("../errors");
const oauth = require("../../redux/reducers/oauth").actions;
const temporary = require("../../redux/reducers/temporary").actions;
const admin = require("../../redux/reducers/admin").actions;
module.exports = function oauthAPI({ apiCall, getCurrentUrl }) {
return {
@ -105,11 +104,8 @@ module.exports = function oauthAPI({ apiCall, getCurrentUrl }) {
// no role info, try fetching an admin-only route and see if we get an error
return Promise.try(() => {
return dispatch(apiCall("GET", "/api/v1/admin/domain_blocks"));
}).then((data) => {
return Promise.all([
dispatch(oauth.setAdmin(true)),
dispatch(admin.setBlockedInstances(data))
]);
}).then(() => {
return dispatch(oauth.setAdmin(true));
}).catch(AuthenticationError, () => {
return dispatch(oauth.setAdmin(false));
});

View file

@ -20,7 +20,6 @@
const {
replaceCacheOnMutation,
appendCacheOnMutation,
removeFromCacheOnMutation,
domainListToObject
} = require("../lib");
@ -60,7 +59,12 @@ const endpoints = (build) => ({
body: formData,
discardEmpty: true
}),
...appendCacheOnMutation("instanceBlocks")
transformResponse: (data) => {
return {
[data.domain]: data
};
},
...replaceCacheOnMutation("instanceBlocks")
}),
removeInstanceBlock: build.mutation({
query: (id) => ({