mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-10-02 01:40:53 +00:00
Fix DM losing conversation list
This commit is contained in:
parent
a885a3d513
commit
4e8cae5191
@ -77,6 +77,7 @@ export type MessagesContextStore = {
|
|||||||
getNextConversationPage: () => void,
|
getNextConversationPage: () => void,
|
||||||
addUserReference: (user: PrimalUser) => void,
|
addUserReference: (user: PrimalUser) => void,
|
||||||
clearAllMessages: () => void,
|
clearAllMessages: () => void,
|
||||||
|
clearReceiver: () => void,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,6 +233,11 @@ export const MessagesProvider = (props: { children: ContextChildren }) => {
|
|||||||
updateStore('senders', reconcile({}));
|
updateStore('senders', reconcile({}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearReceiver = () => {
|
||||||
|
updateStore('activePubkey', () => undefined);
|
||||||
|
currentSender = '';
|
||||||
|
};
|
||||||
|
|
||||||
const getConversationWithSender = (sender: string | null, until = 0) => {
|
const getConversationWithSender = (sender: string | null, until = 0) => {
|
||||||
if (!account?.isKeyLookupDone || !account.hasPublicKey() || !sender) {
|
if (!account?.isKeyLookupDone || !account.hasPublicKey() || !sender) {
|
||||||
return;
|
return;
|
||||||
@ -891,6 +897,7 @@ export const MessagesProvider = (props: { children: ContextChildren }) => {
|
|||||||
getNextConversationPage,
|
getNextConversationPage,
|
||||||
addUserReference,
|
addUserReference,
|
||||||
clearAllMessages,
|
clearAllMessages,
|
||||||
|
clearReceiver,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -195,13 +195,9 @@ const Messages: Component = () => {
|
|||||||
npubToHex(params.sender) :
|
npubToHex(params.sender) :
|
||||||
params.sender;
|
params.sender;
|
||||||
|
|
||||||
const url = currentUrl.startsWith('npub') ?
|
|
||||||
npubToHex(currentUrl) :
|
|
||||||
currentUrl;
|
|
||||||
|
|
||||||
if(currentUrl !== sender) {
|
if(currentUrl !== sender) {
|
||||||
currentUrl = sender;
|
currentUrl = sender;
|
||||||
messages?.actions.selectSender(sender);
|
selectSender(sender);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -622,6 +618,7 @@ const Messages: Component = () => {
|
|||||||
newMessageInput && newMessageInput.removeEventListener('keydown', onKeyDown);
|
newMessageInput && newMessageInput.removeEventListener('keydown', onKeyDown);
|
||||||
messages?.actions.clearAllMessages();
|
messages?.actions.clearAllMessages();
|
||||||
messages?.actions.selectSender();
|
messages?.actions.selectSender();
|
||||||
|
messages?.actions.clearReceiver();
|
||||||
});
|
});
|
||||||
|
|
||||||
const sendMessage = async () => {
|
const sendMessage = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user