Skip to content

Commit

Permalink
update message list to sort by most recent
Browse files Browse the repository at this point in the history
  • Loading branch information
callensm committed Mar 29, 2023
1 parent 12e019c commit fa94e1b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
16 changes: 15 additions & 1 deletion packages/message-sdk/src/components/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ export const MessageList = ({
}) => {
const theme = useCustomTheme();

const sortedChats = activeChats.sort(
(a, b) =>
new Date(
(b.chatType === "collection"
? b.chatProps.lastMessageTimestamp
: b.chatProps.last_message_timestamp) ?? 0
).getTime() -
new Date(
(a.chatType === "collection"
? a.chatProps.lastMessageTimestamp
: a.chatProps.last_message_timestamp) ?? 0
).getTime()
);

return (
<List
style={{
Expand All @@ -58,7 +72,7 @@ export const MessageList = ({
isLast={activeChats?.length === 0}
/>
) : null}
{activeChats?.map((activeChat, index) => (
{sortedChats?.map((activeChat, index) => (
<ChatListItem
toRoot={toRoot}
type={activeChat.chatType}
Expand Down
2 changes: 1 addition & 1 deletion packages/xnft-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"last 1 edge version"
],
"dependencies": {
"@coral-xyz/xnft": "^0.2.42",
"@coral-xyz/xnft": "^0.2.43",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"chokidar": "^3.5.3",
"commander": "^10.0.0",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3783,7 +3783,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@coral-xyz/xnft-cli@workspace:packages/xnft-cli"
dependencies:
"@coral-xyz/xnft": ^0.2.42
"@coral-xyz/xnft": ^0.2.43
"@esbuild-plugins/node-globals-polyfill": ^0.2.3
chokidar: ^3.5.3
commander: ^10.0.0
Expand Down Expand Up @@ -3834,17 +3834,17 @@ __metadata:
languageName: node
linkType: hard

"@coral-xyz/xnft@npm:^0.2.42":
version: 0.2.42
resolution: "@coral-xyz/xnft@npm:0.2.42"
"@coral-xyz/xnft@npm:^0.2.43":
version: 0.2.43
resolution: "@coral-xyz/xnft@npm:0.2.43"
dependencies:
"@coral-xyz/anchor": ^0.27.0
"@metaplex-foundation/js": ^0.17.12
"@solana/spl-token": ^0.3.7
"@solana/web3.js": ^1.74.0
semver: ^7.3.8
zod: ^3.21.4
checksum: 480956d7cde7899dd9b4c9861d12194ccaed18c73a7dfea1359689742b7fed0915d5f9e8a0902f23fcff19d533ebd5c5e50d7adeff2952cd350313e5ef740f22
checksum: 9bb3d22d40856f312f300bb7e45e153e4143b9338c51a563b8ed4d9af1e4315636971aaae3f3651e3032bb9d068ee75c9cd37aebc649257d5b93592418c1c894
languageName: node
linkType: hard

Expand Down

0 comments on commit fa94e1b

Please sign in to comment.