mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-29 23:22:45 +00:00
clean up old redux api+reducers for custom emoji
This commit is contained in:
parent
1e94c50cb9
commit
886e663382
|
@ -160,33 +160,6 @@ module.exports = function ({ apiCall, getChanges }) {
|
|||
});
|
||||
};
|
||||
},
|
||||
|
||||
fetchCustomEmoji: function fetchCustomEmoji() {
|
||||
return function (dispatch, _getState) {
|
||||
return Promise.try(() => {
|
||||
return dispatch(apiCall("GET", "/api/v1/admin/custom_emojis?filter=domain:local&limit=0"));
|
||||
}).then((emoji) => {
|
||||
return dispatch(admin.setEmoji(emoji));
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
newEmoji: function newEmoji() {
|
||||
return function (dispatch, getState) {
|
||||
return Promise.try(() => {
|
||||
const state = getState().admin.newEmoji;
|
||||
|
||||
const update = getChanges(state, {
|
||||
formKeys: ["shortcode"],
|
||||
fileKeys: ["image"]
|
||||
});
|
||||
|
||||
return dispatch(apiCall("POST", "/api/v1/admin/custom_emojis", update, "form"));
|
||||
}).then((emoji) => {
|
||||
return dispatch(admin.addEmoji(emoji));
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
return adminAPI;
|
||||
};
|
|
@ -35,13 +35,6 @@ function emptyBlock() {
|
|||
};
|
||||
}
|
||||
|
||||
function emptyEmojiForm() {
|
||||
return {
|
||||
id: Date.now(),
|
||||
shortcode: ""
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = createSlice({
|
||||
name: "admin",
|
||||
initialState: {
|
||||
|
@ -52,10 +45,7 @@ module.exports = createSlice({
|
|||
exportType: "plain",
|
||||
...emptyBlock()
|
||||
},
|
||||
newInstanceBlocks: {},
|
||||
emoji: {},
|
||||
emojiById: {},
|
||||
newEmoji: emptyEmojiForm()
|
||||
newInstanceBlocks: {}
|
||||
},
|
||||
reducers: {
|
||||
setBlockedInstances: (state, { payload }) => {
|
||||
|
@ -105,34 +95,6 @@ module.exports = createSlice({
|
|||
state.bulkBlock.list = Object.values(state.blockedInstances).map((entry) => {
|
||||
return entry.domain;
|
||||
}).join("\n");
|
||||
},
|
||||
|
||||
setEmoji: (state, {payload}) => {
|
||||
state.emoji = {};
|
||||
payload.forEach((emoji) => {
|
||||
if (emoji.category == undefined) {
|
||||
emoji.category = "Unsorted";
|
||||
}
|
||||
state.emoji[emoji.category] = defaultValue(state.emoji[emoji.category], []);
|
||||
state.emoji[emoji.category].push(emoji);
|
||||
state.emojiById[emoji.id] = emoji;
|
||||
});
|
||||
},
|
||||
|
||||
updateNewEmojiVal: (state, { payload: [key, val] }) => {
|
||||
state.newEmoji[key] = val;
|
||||
},
|
||||
|
||||
addEmoji: (state, {payload: emoji}) => {
|
||||
if (emoji.category == undefined) {
|
||||
emoji.category = "Unsorted";
|
||||
}
|
||||
if (emoji.id == undefined) {
|
||||
emoji.id = Date.now();
|
||||
}
|
||||
state.emoji[emoji.category] = defaultValue(state.emoji[emoji.category], []);
|
||||
state.emoji[emoji.category].push(emoji);
|
||||
state.emojiById[emoji.id] = emoji;
|
||||
},
|
||||
}
|
||||
});
|
Loading…
Reference in a new issue