Persistent message store (#814)
* Fix default filter behaviour * Persist message store * messageStore tests, node PKI validation Implement node validation and improve merging logic - Added `validateIncomingNode` function to validate new nodes against existing nodes, checking for public key conflicts and ensuring proper handling of node updates. - Updated `nodeDBFactory` to utilize the new validation function when adding nodes. - Enhanced `getNodes` method to optionally include the current node in the results. - Removed the `mergeNodeInfo` utility as its functionality is now integrated into the validation and merging process. - Updated tests to cover new validation logic and ensure correct behavior during node addition and merging. - Cleaned up unused utility functions related to key comparison. * refactor: reuse eviction logic for message and node stores * Update format, move hooks * Improve test performance * Update imports --------- Co-authored-by: philon- <philon-@users.noreply.github.com> Co-authored-by: Dan Ditomaso <dan.ditomaso@gmail.com>
This commit is contained in:
co-authored by
philon-
Dan Ditomaso
parent
799283fd46
commit
dcb44d27fe
@@ -12,7 +12,7 @@ import {
|
||||
MessageState,
|
||||
MessageType,
|
||||
useDevice,
|
||||
useMessageStore,
|
||||
useMessages,
|
||||
useNodeDB,
|
||||
useSidebar,
|
||||
} from "@core/stores";
|
||||
@@ -44,9 +44,9 @@ function SelectMessageChat() {
|
||||
|
||||
export const MessagesPage = () => {
|
||||
const { channels, getUnreadCount, resetUnread, connection } = useDevice();
|
||||
const { getNodes, getNode, hasNodeError } = useNodeDB();
|
||||
const { getNodes, getNode, getMyNode, hasNodeError } = useNodeDB();
|
||||
|
||||
const { getMyNodeNum, getMessages, setMessageState } = useMessageStore();
|
||||
const { getMessages, setMessageState } = useMessages();
|
||||
|
||||
const { type, chatId } = useParams({ from: messagesWithParamsRoute.id });
|
||||
|
||||
@@ -77,7 +77,10 @@ export const MessagesPage = () => {
|
||||
useEffect(() => {
|
||||
if (!type && !chatId && filteredChannels.length > 0) {
|
||||
const defaultChannel = filteredChannels[0];
|
||||
navigateToChat(MessageType.Broadcast, defaultChannel.index.toString());
|
||||
navigateToChat(
|
||||
MessageType.Broadcast,
|
||||
defaultChannel?.index.toString() ?? "0",
|
||||
);
|
||||
}
|
||||
}, [type, chatId, filteredChannels, navigateToChat]);
|
||||
|
||||
@@ -138,7 +141,7 @@ export const MessagesPage = () => {
|
||||
} else {
|
||||
setMessageState({
|
||||
type: MessageType.Direct,
|
||||
nodeA: getMyNodeNum(),
|
||||
nodeA: getMyNode().num,
|
||||
nodeB: numericChatId,
|
||||
messageId,
|
||||
newState: MessageState.Ack,
|
||||
@@ -160,7 +163,7 @@ export const MessagesPage = () => {
|
||||
} else {
|
||||
setMessageState({
|
||||
type: MessageType.Direct,
|
||||
nodeA: getMyNodeNum(),
|
||||
nodeA: getMyNode().num,
|
||||
nodeB: numericChatId,
|
||||
messageId: failedId,
|
||||
newState: MessageState.Failed,
|
||||
@@ -168,14 +171,7 @@ export const MessagesPage = () => {
|
||||
}
|
||||
}
|
||||
},
|
||||
[
|
||||
numericChatId,
|
||||
chatType,
|
||||
connection,
|
||||
getMyNodeNum,
|
||||
setMessageState,
|
||||
isDirect,
|
||||
],
|
||||
[numericChatId, chatType, connection, getMyNode, setMessageState, isDirect],
|
||||
);
|
||||
|
||||
const renderChatContent = () => {
|
||||
@@ -194,7 +190,7 @@ export const MessagesPage = () => {
|
||||
<ChannelChat
|
||||
messages={getMessages({
|
||||
type: MessageType.Direct,
|
||||
nodeA: getMyNodeNum(),
|
||||
nodeA: getMyNode().num,
|
||||
nodeB: numericChatId,
|
||||
}).reverse()}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user