ui: UI&UX enhance, bug fixes

Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
undefinedandpanda authored and panda committed 2022-05-10 01:55:20 +08:00
1 parent 3f37b02b79
commit 310189bc4d
37 files changed
+1104 -948

No files matched your search

@@ -21,14 +21,14 @@ function scrollToViewport() {
export default function reducer(state = null, action) {
switch (action.type) {
case 'DIALOGUES_SWITCH_TO': {
scrollToViewport();
return action.payload;
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
return action.meta.dialogueId;
}
default:
return state;
case 'DIALOGUES_SWITCH_TO': {
scrollToViewport();
return action.payload;
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
return action.meta.dialogueId;
}
default:
return state;
}
}
@@ -2,52 +2,52 @@ import _ from 'lodash';
export default function reducer(state = {}, action) {
switch (action.type) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const { messages } = action.payload;
return { ...state, ..._.keyBy(messages, 'udoc._id') };
}
case 'DIALOGUES_CREATE': {
const { user } = action.payload;
if (state[user._id]) return state;
return {
...state,
[user._id]: {
_id: user._id,
udoc: { ...user },
messages: [],
},
};
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
const id = action.meta.dialogueId;
const { mdoc } = action.payload;
return {
...state,
[id]: {
...state[id],
messages: [
...state[id].messages,
mdoc,
],
},
};
}
case 'DIALOGUES_MESSAGE_PUSH': {
const { mdoc, udoc } = action.payload;
const to = mdoc.from === UserContext._id ? mdoc.to : mdoc.from;
return {
...state,
[to]: {
...state[to] || {},
udoc,
messages: [
...state[to]?.messages || [],
mdoc,
],
},
};
}
default:
return state;
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const { messages } = action.payload;
return { ...state, ..._.keyBy(messages, 'udoc._id') };
}
case 'DIALOGUES_CREATE': {
const { user } = action.payload;
if (state[user._id]) return state;
return {
...state,
[user._id]: {
_id: user._id,
udoc: { ...user },
messages: [],
},
};
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
const id = action.meta.dialogueId;
const { mdoc } = action.payload;
return {
...state,
[id]: {
...state[id],
messages: [
...state[id].messages,
mdoc,
],
},
};
}
case 'DIALOGUES_MESSAGE_PUSH': {
const { mdoc, udoc } = action.payload;
const to = mdoc.from === UserContext._id ? mdoc.to : mdoc.from;
return {
...state,
[to]: {
...state[to] || {},
udoc,
messages: [
...state[to]?.messages || [],
mdoc,
],
},
};
}
default:
return state;
}
}
@@ -2,42 +2,42 @@ import _ from 'lodash';
export default function reducer(state = {}, action) {
switch (action.type) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const dialogues = action.payload.messages;
return { ...state, ..._.fromPairs(_.map(dialogues, (d) => [d._id, ''])) };
}
case 'DIALOGUES_CREATE': {
const { user } = action.payload;
return {
...state,
[user._id]: '',
};
}
case 'DIALOGUES_INPUT_CHANGED': {
const id = action.meta.dialogueId;
return {
...state,
[id]: action.payload,
};
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
const id = action.meta.dialogueId;
return {
...state,
[id]: '',
};
}
case 'DIALOGUES_MESSAGE_PUSH': {
const { udoc } = action.payload;
if (!state[udoc._id]) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const dialogues = action.payload.messages;
return { ...state, ..._.fromPairs(_.map(dialogues, (d) => [d._id, ''])) };
}
case 'DIALOGUES_CREATE': {
const { user } = action.payload;
return {
...state,
[udoc._id]: '',
[user._id]: '',
};
}
return state;
}
default:
return state;
case 'DIALOGUES_INPUT_CHANGED': {
const id = action.meta.dialogueId;
return {
...state,
[id]: action.payload,
};
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
const id = action.meta.dialogueId;
return {
...state,
[id]: '',
};
}
case 'DIALOGUES_MESSAGE_PUSH': {
const { udoc } = action.payload;
if (!state[udoc._id]) {
return {
...state,
[udoc._id]: '',
};
}
return state;
}
default:
return state;
}
}
@@ -3,47 +3,47 @@ import Notification from 'vj/components/notification';
export default function reducer(state = {}, action) {
switch (action.type) {
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const dialogues = action.payload.messages;
return { ...state, ..._.fromPairs(_.map(dialogues, (d) => [d._id, false])) };
}
case 'DIALOGUES_CREATE': {
const { user } = action.payload;
return {
...state,
[user._id]: false,
};
}
case 'DIALOGUES_POST_SEND_PENDING': {
const id = action.meta.dialogueId;
return {
...state,
[id]: true,
};
}
case 'DIALOGUES_POST_SEND_REJECTED': {
Notification.error(action.payload.message);
const id = action.meta.dialogueId;
return {
...state,
[id]: false,
};
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
const id = action.meta.dialogueId;
return {
...state,
[id]: false,
};
}
case 'DIALOGUES_MESSAGE_PUSH': {
const { udoc } = action.payload;
return {
...state,
[udoc._id]: false,
};
}
default:
return state;
case 'DIALOGUES_LOAD_DIALOGUES_FULFILLED': {
const dialogues = action.payload.messages;
return { ...state, ..._.fromPairs(_.map(dialogues, (d) => [d._id, false])) };
}
case 'DIALOGUES_CREATE': {
const { user } = action.payload;
return {
...state,
[user._id]: false,
};
}
case 'DIALOGUES_POST_SEND_PENDING': {
const id = action.meta.dialogueId;
return {
...state,
[id]: true,
};
}
case 'DIALOGUES_POST_SEND_REJECTED': {
Notification.error(action.payload.message);
const id = action.meta.dialogueId;
return {
...state,
[id]: false,
};
}
case 'DIALOGUES_POST_SEND_FULFILLED': {
const id = action.meta.dialogueId;
return {
...state,
[id]: false,
};
}
case 'DIALOGUES_MESSAGE_PUSH': {
const { udoc } = action.payload;
return {
...state,
[udoc._id]: false,
};
}
default:
return state;
}
}