mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
optimizing topic load
This commit is contained in:
parent
e4f55861d0
commit
f5e27c80e1
@ -61,6 +61,7 @@ export function useConversationContext() {
|
|||||||
const cardValue = cardId ? card.state.cards.get(cardId) : null;
|
const cardValue = cardId ? card.state.cards.get(cardId) : null;
|
||||||
const channelValue = cardId ? cardValue?.channels.get(channelId) : channel.state.channels.get(channelId);
|
const channelValue = cardId ? cardValue?.channels.get(channelId) : channel.state.channels.get(channelId);
|
||||||
const { topicRevision } = channelValue || {};
|
const { topicRevision } = channelValue || {};
|
||||||
|
let setChannel = false;
|
||||||
|
|
||||||
if (channelValue) {
|
if (channelValue) {
|
||||||
if (!loaded.current) {
|
if (!loaded.current) {
|
||||||
@ -75,6 +76,9 @@ export function useConversationContext() {
|
|||||||
curTopicMarker.current = topicMarker;
|
curTopicMarker.current = topicMarker;
|
||||||
loaded.current = true;
|
loaded.current = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
setChannel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("failed to load conversation");
|
console.log("failed to load conversation");
|
||||||
@ -89,20 +93,25 @@ export function useConversationContext() {
|
|||||||
await setMarkerAndSync(cardId, channelId, delta.marker, topicRevision);
|
await setMarkerAndSync(cardId, channelId, delta.marker, topicRevision);
|
||||||
curTopicMarker.current = delta.marker;
|
curTopicMarker.current = delta.marker;
|
||||||
curSyncRevision.current = topicRevision;
|
curSyncRevision.current = topicRevision;
|
||||||
|
updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
|
||||||
}
|
}
|
||||||
if (loadMore && marker) {
|
else if (loadMore && marker) {
|
||||||
const delta = await getTopicDelta(cardId, channelId, null, COUNT, null, curTopicMarker.current);
|
const delta = await getTopicDelta(cardId, channelId, null, COUNT, null, curTopicMarker.current);
|
||||||
await setTopicDelta(cardId, channelId, delta.topics);
|
await setTopicDelta(cardId, channelId, delta.topics);
|
||||||
await setTopicMarker(cardId, channelId, delta.marker);
|
await setTopicMarker(cardId, channelId, delta.marker);
|
||||||
curTopicMarker.current = delta.marker;
|
curTopicMarker.current = delta.marker;
|
||||||
|
updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
|
||||||
}
|
}
|
||||||
if (ignoreRevision || topicRevision !== curSyncRevision.current) {
|
else if (ignoreRevision || topicRevision !== curSyncRevision.current) {
|
||||||
const delta = await getTopicDelta(cardId, channelId, curSyncRevision.current, null, curTopicMarker.current, null);
|
const delta = await getTopicDelta(cardId, channelId, curSyncRevision.current, null, curTopicMarker.current, null);
|
||||||
await setTopicDelta(cardId, channelId, delta.topics);
|
await setTopicDelta(cardId, channelId, delta.topics);
|
||||||
await setSyncRevision(cardId, channelId, topicRevision);
|
await setSyncRevision(cardId, channelId, topicRevision);
|
||||||
curSyncRevision.current = topicRevision;
|
curSyncRevision.current = topicRevision;
|
||||||
|
updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
|
||||||
|
}
|
||||||
|
else if (setChannel) {
|
||||||
|
updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
|
||||||
}
|
}
|
||||||
updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
|
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user