chore: update prettier setting

This commit is contained in:
zerosoul
2022-06-12 15:30:14 +08:00
parent 14b4678d9e
commit 516794d352
209 changed files with 2435 additions and 4588 deletions
+8 -19
View File
@@ -1,24 +1,18 @@
import { createSlice } from "@reduxjs/toolkit";
import {
KEY_PWA_INSTALLED,
KEY_REFRESH_TOKEN,
KEY_TOKEN,
KEY_UID,
KEY_EXPIRE,
} from "../config";
import { KEY_PWA_INSTALLED, KEY_REFRESH_TOKEN, KEY_TOKEN, KEY_UID, KEY_EXPIRE } from "../config";
const initialState = {
initialized: true,
uid: null,
token: localStorage.getItem(KEY_TOKEN),
expireTime: localStorage.getItem(KEY_EXPIRE) || +new Date(),
refreshToken: localStorage.getItem(KEY_REFRESH_TOKEN),
refreshToken: localStorage.getItem(KEY_REFRESH_TOKEN)
};
const emptyState = {
initialized: true,
uid: null,
token: null,
expireTime: +new Date(),
refreshToken: null,
refreshToken: null
};
const authDataSlice = createSlice({
name: "authData",
@@ -30,7 +24,7 @@ const authDataSlice = createSlice({
user: { uid },
token,
refresh_token,
expired_in = 0,
expired_in = 0
} = action.payload;
state.initialized = initialized;
state.uid = uid;
@@ -76,14 +70,9 @@ const authDataSlice = createSlice({
localStorage.setItem(KEY_EXPIRE, et);
localStorage.setItem(KEY_TOKEN, token);
localStorage.setItem(KEY_REFRESH_TOKEN, refresh_token);
},
},
}
}
});
export const {
updateInitialized,
setAuthData,
resetAuthData,
setUid,
updateToken,
} = authDataSlice.actions;
export const { updateInitialized, setAuthData, resetAuthData, setUid, updateToken } =
authDataSlice.actions;
export default authDataSlice.reducer;
+6 -10
View File
@@ -3,7 +3,7 @@ import BASE_URL from "../config";
import { getNonNullValues } from "../../common/utils";
const initialState = {
ids: [],
byId: {},
byId: {}
};
const channelsSlice = createSlice({
name: `channels`,
@@ -36,18 +36,14 @@ const channelsSlice = createSlice({
icon:
avatar_updated_at == 0
? ""
: `${BASE_URL}/resource/group_avatar?gid=${gid}&t=${avatar_updated_at}`,
: `${BASE_URL}/resource/group_avatar?gid=${gid}&t=${avatar_updated_at}`
};
},
updateChannel(state, action) {
const ignoreInPublic = ["add_member", "remove_member"];
const { id, operation, members = [], ...rest } = action.payload;
const currChannel = state.byId[id];
if (
!currChannel ||
(currChannel.is_public && ignoreInPublic.includes(operation))
)
return;
if (!currChannel || (currChannel.is_public && ignoreInPublic.includes(operation))) return;
switch (operation) {
case "remove_member":
{
@@ -99,8 +95,8 @@ const channelsSlice = createSlice({
state.ids.splice(idx, 1);
delete state.byId[gid];
}
},
},
}
}
});
export const {
updatePinMessage,
@@ -108,6 +104,6 @@ export const {
fullfillChannels,
addChannel,
updateChannel,
removeChannel,
removeChannel
} = channelsSlice.actions;
export default channelsSlice.reducer;
+6 -12
View File
@@ -3,7 +3,7 @@ import { getNonNullValues } from "../../common/utils";
import BASE_URL from "../config";
const initialState = {
ids: [],
byId: {},
byId: {}
};
const contactsSlice = createSlice({
name: `contacts`,
@@ -39,9 +39,7 @@ const contactsSlice = createSlice({
Object.keys(vals).forEach((k) => {
state.byId[uid][k] = vals[k];
if (k == "avatar_updated_at") {
state.byId[
uid
].avatar = `${BASE_URL}/resource/avatar?uid=${uid}&t=${vals[k]}`;
state.byId[uid].avatar = `${BASE_URL}/resource/avatar?uid=${uid}&t=${vals[k]}`;
}
});
}
@@ -80,13 +78,9 @@ const contactsSlice = createSlice({
state.byId[uid].online = online;
}
});
},
},
}
}
});
export const {
resetContacts,
fullfillContacts,
updateUsersByLogs,
updateUsersStatus,
} = contactsSlice.actions;
export const { resetContacts, fullfillContacts, updateUsersByLogs, updateUsersStatus } =
contactsSlice.actions;
export default contactsSlice.reducer;
+4 -8
View File
@@ -24,13 +24,9 @@ const favoritesSlice = createSlice({
if (idx > -1) {
state[idx].messages = messages;
}
},
},
}
}
});
export const {
addFavorite,
deleteFavorite,
fullfillFavorites,
populateFavorite,
} = favoritesSlice.actions;
export const { addFavorite, deleteFavorite, fullfillFavorites, populateFavorite } =
favoritesSlice.actions;
export default favoritesSlice.reducer;
+6 -6
View File
@@ -5,7 +5,7 @@ const initialState = {
readUsers: {},
readChannels: {},
muteUsers: {},
muteChannels: {},
muteChannels: {}
};
const footprintSlice = createSlice({
name: "footprint",
@@ -21,7 +21,7 @@ const footprintSlice = createSlice({
readUsers = {},
readChannels = {},
muteUsers = {},
muteChannels = {},
muteChannels = {}
} = action.payload;
return {
usersVersion,
@@ -29,7 +29,7 @@ const footprintSlice = createSlice({
readUsers,
readChannels,
muteUsers,
muteChannels,
muteChannels
};
},
updateUsersVersion(state, action) {
@@ -94,8 +94,8 @@ const footprintSlice = createSlice({
reads.forEach(({ gid, mid }) => {
state.readChannels[gid] = mid;
});
},
},
}
}
});
export const {
resetFootprint,
@@ -104,6 +104,6 @@ export const {
updateUsersVersion,
updateReadChannels,
updateReadUsers,
updateMute,
updateMute
} = footprintSlice.actions;
export default footprintSlice.reducer;
+5 -8
View File
@@ -15,8 +15,7 @@ const channelMsgSlice = createSlice({
const { id, mid, local_id = null } = action.payload;
if (state[id]) {
const midExsited = state[id].findIndex((id) => id == mid) > -1;
const localMsgExsited =
state[id].findIndex((id) => id == local_id) > -1;
const localMsgExsited = state[id].findIndex((id) => id == local_id) > -1;
if (midExsited || localMsgExsited) return;
state[id].push(+mid);
} else {
@@ -44,14 +43,12 @@ const channelMsgSlice = createSlice({
}
},
removeChannelSession(state, action) {
const ids = Array.isArray(action.payload)
? action.payload
: [action.payload];
const ids = Array.isArray(action.payload) ? action.payload : [action.payload];
ids.forEach((id) => {
delete state[id];
});
},
},
}
}
});
export const {
removeChannelSession,
@@ -59,6 +56,6 @@ export const {
fullfillChannelMsg,
addChannelMsg,
removeChannelMsg,
replaceChannelMsg,
replaceChannelMsg
} = channelMsgSlice.actions;
export default channelMsgSlice.reducer;
+5 -11
View File
@@ -20,9 +20,7 @@ const fileMessageSlice = createSlice({
}
},
removeFileMessage(state, action) {
const mids = Array.isArray(action.payload)
? action.payload
: [action.payload];
const mids = Array.isArray(action.payload) ? action.payload : [action.payload];
mids.forEach((id) => {
// 从file message 列表删掉
const fidIdx = state.findIndex((fid) => fid == id);
@@ -30,13 +28,9 @@ const fileMessageSlice = createSlice({
state.splice(fidIdx, 1);
}
});
},
},
}
}
});
export const {
removeFileMessage,
resetFileMessage,
fullfillFileMessage,
addFileMessage,
} = fileMessageSlice.actions;
export const { removeFileMessage, resetFileMessage, fullfillFileMessage, addFileMessage } =
fileMessageSlice.actions;
export default fileMessageSlice.reducer;
+5 -7
View File
@@ -2,7 +2,7 @@ import { createSlice } from "@reduxjs/toolkit";
import BASE_URL, { ContentTypes } from "../config";
import { isImage } from "../../common/utils";
const initialState = {
replying: {},
replying: {}
};
const messageSlice = createSlice({
name: "message",
@@ -48,9 +48,7 @@ const messageSlice = createSlice({
state[mid] = data;
},
removeMessage(state, action) {
const mids = Array.isArray(action.payload)
? action.payload
: [action.payload];
const mids = Array.isArray(action.payload) ? action.payload : [action.payload];
mids.forEach((id) => {
delete state[id];
});
@@ -65,8 +63,8 @@ const messageSlice = createSlice({
if (state.replying[key]) {
delete state.replying[key];
}
},
},
}
}
});
export const {
resetMessage,
@@ -76,6 +74,6 @@ export const {
addMessage,
removeMessage,
addReplyingMessage,
removeReplyingMessage,
removeReplyingMessage
} = messageSlice.actions;
export default messageSlice.reducer;
+4 -6
View File
@@ -12,9 +12,7 @@ const reactionMessageSlice = createSlice({
return action.payload;
},
removeReactionMessage(state, action) {
const mids = Array.isArray(action.payload)
? action.payload
: [action.payload];
const mids = Array.isArray(action.payload) ? action.payload : [action.payload];
mids.forEach((id) => {
delete state[id];
});
@@ -48,13 +46,13 @@ const reactionMessageSlice = createSlice({
state[mid][reaction] = [from_uid];
}
state[rid] = true;
},
},
}
}
});
export const {
removeReactionMessage,
resetReactionMessage,
fullfillReactionMessage,
toggleReactionMessage,
toggleReactionMessage
} = reactionMessageSlice.actions;
export default reactionMessageSlice.reducer;
+6 -9
View File
@@ -1,7 +1,7 @@
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
ids: [],
byId: {},
byId: {}
};
const userMsgSlice = createSlice({
name: "userMessage",
@@ -18,8 +18,7 @@ const userMsgSlice = createSlice({
const { id, mid, local_id } = action.payload;
if (state.byId[id]) {
const midExsited = state.byId[id].findIndex((id) => id == mid) > -1;
const localMsgExsited =
state.byId[id].findIndex((id) => id == local_id) > -1;
const localMsgExsited = state.byId[id].findIndex((id) => id == local_id) > -1;
if (midExsited || localMsgExsited) return;
state.byId[id].push(+mid);
@@ -53,15 +52,13 @@ const userMsgSlice = createSlice({
}
},
removeUserSession(state, action) {
const ids = Array.isArray(action.payload)
? action.payload
: [action.payload];
const ids = Array.isArray(action.payload) ? action.payload : [action.payload];
state.ids = state.ids.filter((id) => ids.findIndex((i) => i == id) == -1);
// ids.forEach((id) => {
// delete state.byId[id];
// });
},
},
}
}
});
export const {
removeUserSession,
@@ -69,6 +66,6 @@ export const {
fullfillUserMsg,
addUserMsg,
removeUserMsg,
replaceUserMsg,
replaceUserMsg
} = userMsgSlice.actions;
export default userMsgSlice.reducer;
+1 -1
View File
@@ -4,4 +4,4 @@ set
add
update
remove
toggle
toggle
+6 -6
View File
@@ -5,8 +5,8 @@ const initialState = {
logo: "",
inviteLink: {
link: "",
expire: 0,
},
expire: 0
}
};
const serverSlice = createSlice({
name: "server",
@@ -19,10 +19,10 @@ const serverSlice = createSlice({
const {
inviteLink = {
link: "",
expire: 0,
expire: 0
},
name = "",
description = "",
description = ""
} = action.payload || {};
return { name, description, inviteLink };
},
@@ -31,8 +31,8 @@ const serverSlice = createSlice({
Object.keys(values).forEach((_key) => {
state[_key] = values[_key];
});
},
},
}
}
});
export const { updateInfo, resetServer, fullfillServer } = serverSlice.actions;
export default serverSlice.reducer;
+8 -18
View File
@@ -5,7 +5,7 @@ const initialState = {
ready: false,
userGuide: {
visible: false,
step: 1,
step: 1
},
inputMode: "text",
menuExpand: false,
@@ -16,8 +16,8 @@ const initialState = {
draftMixedText: {},
remeberedNavs: {
chat: null,
contact: null,
},
contact: null
}
};
const uiSlice = createSlice({
name: "ui",
@@ -61,12 +61,7 @@ const uiSlice = createSlice({
},
updateUploadFiles(state, action) {
const {
context = "channel",
id = null,
operation = "add",
...rest
} = action.payload;
const { context = "channel", id = null, operation = "add", ...rest } = action.payload;
if (!id || !context) return;
const _key = `${context}_${id}`;
let files = state.uploadFiles[_key];
@@ -126,12 +121,7 @@ const uiSlice = createSlice({
}
},
updateSelectMessages(state, action) {
const {
context = "channel",
id = null,
operation = "add",
data = null,
} = action.payload;
const { context = "channel", id = null, operation = "add", data = null } = action.payload;
let currData = state.selectMessages[`${context}_${id}`];
switch (operation) {
case "add": {
@@ -151,8 +141,8 @@ const uiSlice = createSlice({
break;
}
state.selectMessages[`${context}_${id}`] = currData;
},
},
}
}
});
export const {
fullfillUI,
@@ -166,6 +156,6 @@ export const {
updateUserGuide,
updateDraftMarkdown,
updateDraftMixedText,
updateRemeberedNavs,
updateRemeberedNavs
} = uiSlice.actions;
export default uiSlice.reducer;