Skip to content

Commit

Permalink
fix(sense): scroll messages in viewer bugfix (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
dasein108 authored Mar 26, 2024
1 parent bf59d62 commit 92fe171
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/features/sense/ui/SenseViewer/Messages/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ function Messages({ messages, currentChatId }: Props) {
);
}

const messagesByDate = useMemo(() => {
const msgs = [...messages].reverse().slice(0, showItemsLength);
const messagesByDateAll = useMemo(() => {
return Object.entries(
[...messages].reverse().reduce<{
[date: string]: SenseItem[];
}>((acc, senseItem) => {
const date = dateFormat(senseItem.timestamp, 'yyyy-mm-dd');

const messagesByDate = msgs.reduce<{
[date: string]: SenseItem[];
}>((acc, senseItem) => {
const date = dateFormat(senseItem.timestamp, 'yyyy-mm-dd');
if (!acc[date]) {
acc[date] = [];
}

if (!acc[date]) {
acc[date] = [];
}
acc[date].push(senseItem);

acc[date].push(senseItem);

return acc;
}, {});

// maybe need order?
const arr = Object.entries(messagesByDate);
return acc;
}, {})
);
}, [messages]);

return arr;
}, [messages, showItemsLength]);
const messagesByDate = useMemo(
() => messagesByDateAll.slice(0, showItemsLength),
[messagesByDateAll, showItemsLength]
);

return (
// wrappers for correct scroll
Expand Down

0 comments on commit 92fe171

Please sign in to comment.