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), oauth: require("./oauth")(submoduleArgs),
user: require("./user")(submoduleArgs), user: require("./user")(submoduleArgs),
admin: require("./admin")(submoduleArgs),
apiCall, apiCall,
convertToForm, convertToForm,
getChanges getChanges

View file

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

View file

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