diff --git a/app/mobile/src/context/useCardContext.hook.js b/app/mobile/src/context/useCardContext.hook.js
index 613a90c5..f09b6c44 100644
--- a/app/mobile/src/context/useCardContext.hook.js
+++ b/app/mobile/src/context/useCardContext.hook.js
@@ -365,7 +365,7 @@ export function useCardContext() {
curRevision.current = rev;
sync();
},
- setReadRevision: async (cardId, channelId, rev) => {
+ setChannelReadRevision: async (cardId, channelId, rev) => {
await store.actions.setCardChannelItemReadRevision(session.current.guid, cardId, channelId, rev);
setCardChannelReadRevision(cardId, channelId, rev);
updateState({ cards: cards.current });
diff --git a/app/mobile/src/context/useConversationContext.hook.js b/app/mobile/src/context/useConversationContext.hook.js
index 1e4ad4c0..047dbf16 100644
--- a/app/mobile/src/context/useConversationContext.hook.js
+++ b/app/mobile/src/context/useConversationContext.hook.js
@@ -259,19 +259,26 @@ console.log("update:", topics.current.size);
}, [card, channel]);
const actions = {
- setChannel: (channel) => {
- if (channel == null) {
+ setChannel: (selected) => {
+ if (selected == null) {
setView.current++;
conversationId.current = null;
reset.current = true;
updateState({ subject: null, logo: null, contacts: [], topics: new Map() });
}
- else if (channel.cardId !== conversationId.current?.cardId || channel.channelId !== conversationId.current?.channelId) {
+ else if (selected.cardId !== conversationId.current?.cardId || selected.channelId !== conversationId.current?.channelId) {
setView.current++;
- conversationId.current = channel;
+ conversationId.current = selected;
reset.current = true;
updateState({ subject: null, logo: null, contacts: [], topics: new Map() });
sync();
+ const { cardId, channelId, revision } = selected;
+ if (cardId) {
+ card.actions.setChannelReadRevision(cardId, channelId, revision);
+ }
+ else {
+ channel.actions.setReadRevision(channelId, revision);
+ }
}
},
}
diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx
index 37374f44..cbe9d217 100644
--- a/app/mobile/src/session/Session.jsx
+++ b/app/mobile/src/session/Session.jsx
@@ -37,27 +37,12 @@ export function Session() {
const { state, actions } = useSession();
- const openCards = (nav) => {
- nav.openDrawer();
- }
- const closeCards = (nav) => {}
- const openProfile = (nav) => {
- nav.openDrawer();
- }
- const closeProfile = (nav) => {}
- const openContact = (nav, cardId) => {}
- const closeContact = (nav) => {}
- const openConversation = (nav, cardId, channelId) => {}
- const closeConversation = (nav) => {}
- const openDetails = (nav, cardId, channeId) => {}
- const closeDetails = (nav) => {}
-
// tabbed containers
const ConversationStackScreen = () => {
const [selected, setSelected] = useState(null);
- const setConversation = (navigation, cardId, channelId) => {
- setSelected({ cardId, channelId });
+ const setConversation = (navigation, cardId, channelId, revision) => {
+ setSelected({ cardId, channelId, revision });
navigation.navigate('conversation');
}
const clearConversation = (navigation) => {
@@ -91,7 +76,7 @@ export function Session() {
headerBackTitleVisible: false,
headerTitle: (props) =>
}}>
- {(props) => setConversation(props.navigation, cardId, channelId)} />}
+ {(props) => setConversation(props.navigation, cardId, channelId, revision)} />}
{
const [channel, setChannel] = useState(null);
- const setConversation = (cardId, channelId) => {
- setChannel({ cardId, channelId });
+ const setConversation = (cardId, channelId, revision) => {
+ setChannel({ cardId, channelId, revision });
};
const clearConversation = () => {
setChannel(null);
diff --git a/app/mobile/src/session/channels/channelItem/ChannelItem.jsx b/app/mobile/src/session/channels/channelItem/ChannelItem.jsx
index ea31739e..d2701fdd 100644
--- a/app/mobile/src/session/channels/channelItem/ChannelItem.jsx
+++ b/app/mobile/src/session/channels/channelItem/ChannelItem.jsx
@@ -8,7 +8,7 @@ export function ChannelItem({ item, openConversation }) {
const { state, actions } = useChannelItem(item);
return (
- openConversation(item.cardId, item.channelId)}>
+ openConversation(item.cardId, item.channelId, item.revision)}>
{ item.subject }
diff --git a/app/mobile/src/session/channels/useChannels.hook.js b/app/mobile/src/session/channels/useChannels.hook.js
index 95f79bc4..13d1d85b 100644
--- a/app/mobile/src/session/channels/useChannels.hook.js
+++ b/app/mobile/src/session/channels/useChannels.hook.js
@@ -124,7 +124,9 @@ export function useChannels() {
}
}
- return { cardId: item.cardId, channelId: item.channelId, contacts, logo, subject, message, updated, revision: item.revision };
+ const timestamp = item?.summary?.lastTopic?.created;
+
+ return { cardId: item.cardId, channelId: item.channelId, contacts, logo, subject, message, updated, revision: item.revision, timestamp };
}
useEffect(() => {
@@ -152,8 +154,8 @@ export function useChannels() {
});
const sorted = filtered.sort((a, b) => {
- const aCreated = a?.summary?.lastTopic?.created;
- const bCreated = b?.summary?.lastTopic?.created;
+ const aCreated = a?.timestamp;
+ const bCreated = b?.timestamp;
if (aCreated === bCreated) {
return 0;
}