mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[frontend] Custom Emoji Deletion (#994)
* re-add eslint * fix oauth url getting too long * actually attach single emoji get and delete routes * basic emoji details + deletion using rtk query * refactor emoji upload to rtk query * clean up old redux api+reducers for custom emoji * fix validation order * refactor custom emoji form fields * remove unused requires * cleanup, fix most eslint errors * more small eslint fixes * fix max emoji size * tiny bit of function documentation
This commit is contained in:
@ -19,7 +19,6 @@
|
||||
"use strict";
|
||||
|
||||
const { createSlice } = require("@reduxjs/toolkit");
|
||||
const defaultValue = require("default-value");
|
||||
|
||||
function sortBlocks(blocks) {
|
||||
return blocks.sort((a, b) => { // alphabetical sort
|
||||
@ -35,13 +34,6 @@ function emptyBlock() {
|
||||
};
|
||||
}
|
||||
|
||||
function emptyEmojiForm() {
|
||||
return {
|
||||
id: Date.now(),
|
||||
shortcode: ""
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = createSlice({
|
||||
name: "admin",
|
||||
initialState: {
|
||||
@ -52,10 +44,7 @@ module.exports = createSlice({
|
||||
exportType: "plain",
|
||||
...emptyBlock()
|
||||
},
|
||||
newInstanceBlocks: {},
|
||||
emoji: {},
|
||||
emojiById: {},
|
||||
newEmoji: emptyEmojiForm()
|
||||
newInstanceBlocks: {}
|
||||
},
|
||||
reducers: {
|
||||
setBlockedInstances: (state, { payload }) => {
|
||||
@ -105,34 +94,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;
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user