Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"start:prod": "NODE_ENV=production node build/server.js"
},
"dependencies": {
"@ecency/ns-query": "^1.0.7",
"@ecency/ns-query": "^1.0.8",
"@ecency/render-helper": "^2.2.29",
"@ecency/render-helper-amp": "^1.1.0",
"@emoji-mart/data": "^1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function ChatPopupContactsAndChannels({
isLink={false}
contact={user}
onClick={() => userClicked(user.name)}
key={user.pubkey + user.unread}
key={user.pubkey}
/>
))}
</>
Expand Down
9 changes: 6 additions & 3 deletions src/common/features/chats/components/chat-popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
useDirectContactsQuery,
useJoinChat,
useKeysQuery,
useUpdateDirectContactsUnreadCount
useUpdateDirectContactsLastSeenDate
} from "@ecency/ns-query";
import { ChatInvitation } from "../chat-invitation";

Expand Down Expand Up @@ -62,7 +62,7 @@ export const ChatPopUp = () => {
[hasUserJoinedChat, privateKey, currentChannel, revealPrivateKey]
);

const updateDirectContactsUnreadCount = useUpdateDirectContactsUnreadCount();
const updateDirectContactsLastSeenDate = useUpdateDirectContactsLastSeenDate();

useMount(() => {
setShow(!routerLocation.pathname.match("/chats") && !!activeUser);
Expand All @@ -82,7 +82,10 @@ export const ChatPopUp = () => {
// Whenever current contact is exists need to turn unread to 0
useEffect(() => {
if (currentContact) {
updateDirectContactsUnreadCount.mutateAsync({ contact: currentContact, unread: 0 });
updateDirectContactsLastSeenDate.mutateAsync({
contact: currentContact,
lastSeenDate: new Date()
});
}
}, [currentContact]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
getRelativeDate,
useGetPublicKeysQuery,
useKeysQuery,
useLastMessageQuery
useLastMessageQuery,
useUnreadCountQuery
} from "@ecency/ns-query";
import { _t } from "../../../../i18n";
import Tooltip from "../../../../components/tooltip";
Expand All @@ -31,8 +32,9 @@ export function ChatSidebarDirectContact({ contact, onClick, isLink = true }: Pr
contact.name
);
const lastMessage = useLastMessageQuery(contact);
const lastMessageDate = useMemo(() => getRelativeDate(lastMessage?.created), [lastMessage]);
const unread = useUnreadCountQuery(contact);

const lastMessageDate = useMemo(() => getRelativeDate(lastMessage?.created), [lastMessage]);
const isJoined = useMemo(() => (contactKeys ? contactKeys.pubkey : false), [contactKeys]);
const isReadOnly = useMemo(
() => (contactKeys && isJoined ? contact.pubkey !== contactKeys.pubkey : false),
Expand Down Expand Up @@ -78,7 +80,7 @@ export function ChatSidebarDirectContact({ contact, onClick, isLink = true }: Pr
)}
{lastMessage?.content}
</div>
{!!contact.unread && <Badge appearance="secondary">{contact.unread}</Badge>}
{!!unread && <Badge appearance="secondary">{unread}</Badge>}
</div>
</div>
</>
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1374,10 +1374,10 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==

"@ecency/ns-query@^1.0.7":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@ecency/ns-query/-/ns-query-1.0.7.tgz#edbc988ee553ee3707f13d14d2a3cf166019f051"
integrity sha512-uYus9nlmxl2R/vgPQgAj4RGIioXfrEZLrJH0eS2LJfxIkxhaAOWk2s07cnY7ewcgf+R744l287EOsH2tR1bYGg==
"@ecency/ns-query@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@ecency/ns-query/-/ns-query-1.0.8.tgz#c1661a28b42dbe97074224148a140108c7026df4"
integrity sha512-kZgJJ+w5tCQxOopNrxvNoGzWPfxQzLKwejqkzR1QxyjVwL3GasKqvId3G1lQ0HzW+J2/cvmSkj0dZJMJueUOrA==
dependencies:
"@tanstack/react-query" "^4.29.7"
axios "^0.21.2"
Expand Down