mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
set read marker
This commit is contained in:
parent
db7eff8a51
commit
720e242c79
@ -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 });
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -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) => <ChannelsTitle state={channels.state} actions={channels.actions} />
|
||||
}}>
|
||||
{(props) => <ChannelsBody state={channels.state} actions={channels.actions} openConversation={(cardId, channelId) => setConversation(props.navigation, cardId, channelId)} />}
|
||||
{(props) => <ChannelsBody state={channels.state} actions={channels.actions} openConversation={(cardId, channelId, revision) => setConversation(props.navigation, cardId, channelId, revision)} />}
|
||||
</ConversationStack.Screen>
|
||||
<ConversationStack.Screen name="conversation" options={{
|
||||
headerStyle: { backgroundColor: Colors.titleBackground },
|
||||
@ -166,8 +151,8 @@ export function Session() {
|
||||
const HomeScreen = ({ cardNav, registryNav, detailNav, contactNav, profileNav, setDetails, resetConversation, clearReset }) => {
|
||||
|
||||
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);
|
||||
|
@ -8,7 +8,7 @@ export function ChannelItem({ item, openConversation }) {
|
||||
const { state, actions } = useChannelItem(item);
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={styles.container} activeOpacity={1} onPress={() => openConversation(item.cardId, item.channelId)}>
|
||||
<TouchableOpacity style={styles.container} activeOpacity={1} onPress={() => openConversation(item.cardId, item.channelId, item.revision)}>
|
||||
<Logo src={item.logo} width={32} height={32} radius={6} />
|
||||
<View style={styles.detail}>
|
||||
<Text style={styles.subject} numberOfLines={1} ellipsizeMode={'tail'}>{ item.subject }</Text>
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user