diff --git a/app/mobile/ios/Databag.xcodeproj/project.pbxproj b/app/mobile/ios/Databag.xcodeproj/project.pbxproj
index d6343f17..e18215b7 100644
--- a/app/mobile/ios/Databag.xcodeproj/project.pbxproj
+++ b/app/mobile/ios/Databag.xcodeproj/project.pbxproj
@@ -567,7 +567,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
- CLANG_CXX_LANGUAGE_STANDARD = "c++14";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
@@ -639,7 +639,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
- CLANG_CXX_LANGUAGE_STANDARD = "c++14";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
diff --git a/app/mobile/src/api/getContactChannelTopics.js b/app/mobile/src/api/getContactChannelTopics.js
index cf55dd36..b63a3b8f 100644
--- a/app/mobile/src/api/getContactChannelTopics.js
+++ b/app/mobile/src/api/getContactChannelTopics.js
@@ -1,6 +1,10 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannelTopics(server, token, channelId, revision, count, begin, end) {
+
+console.log("GETTING:", revision, count, begin, end);
+
+
let rev = ''
if (revision != null) {
rev = `&revision=${revision}`
@@ -20,6 +24,9 @@ export async function getContactChannelTopics(server, token, channelId, revision
let topics = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}${rev}${cnt}${bgn}${edn}`,
{ method: 'GET' });
checkResponse(topics)
+
+console.log(topics.headers);
+
return {
marker: topics.headers.get('topic-marker'),
revision: topics.headers.get('topic-revision'),
diff --git a/app/mobile/src/context/useCardContext.hook.js b/app/mobile/src/context/useCardContext.hook.js
index 3fa1fba3..5c567c53 100644
--- a/app/mobile/src/context/useCardContext.hook.js
+++ b/app/mobile/src/context/useCardContext.hook.js
@@ -411,7 +411,7 @@ export function useCardContext() {
getTopics: async (cardId, channelId, revision, count, begin, end) => {
const { detail, profile } = (cards.current.get(cardId) || {}).card;
const cardToken = `${profile?.guid}.${detail?.token}`;
- return await getContactChannelTopics(profile?.node, cardToken, channelId);
+ return await getContactChannelTopics(profile?.node, cardToken, channelId, revision, count, begin, end);
},
getTopic: async (cardId, channelId, topicId) => {
const { detail, profile } = (cards.current.get(cardId) || {}).card;
diff --git a/app/mobile/src/context/useConversationContext.hook.js b/app/mobile/src/context/useConversationContext.hook.js
index 80ad1b6e..f027765b 100644
--- a/app/mobile/src/context/useConversationContext.hook.js
+++ b/app/mobile/src/context/useConversationContext.hook.js
@@ -28,18 +28,21 @@ export function useConversationContext() {
const conversationId = useRef(null);
const topics = useRef(new Map());
+ const curSyncRevision = useRef();
+ const curTopicMarker = useRef();
+
const updateState = (value) => {
setState((s) => ({ ...s, ...value }))
}
const sync = async () => {
-console.log("SYNCING!");
if (!syncing.current && (reset.current || update.current || force.current || more.current)) {
+
+console.log("SYNCING!", reset.current, update.current, force.current, more.current);
const loadMore = more.current;
const ignoreRevision = force.current;
const conversation = conversationId.current;
- let curRevision, setRevision, marker;
syncing.current = true;
update.current = false;
@@ -50,39 +53,30 @@ console.log("SYNCING!");
reset.current = false;
loaded.current = false;
topics.current = new Map();
-
- let notification;
- try {
- notification = await getNotifications();
- }
- catch(err) {
- console.log(err);
- }
-
- updateState({ offsync: false, channel: null, card: null, topics: topics.current, notification });
}
if (conversation) {
const { cardId, channelId } = conversation;
const cardValue = cardId ? card.state.cards.get(cardId) : null;
const channelValue = cardId ? cardValue?.channels.get(channelId) : channel.state.channels.get(channelId);
+ const { topicRevision } = channelValue || {};
if (channelValue) {
- const { topicRevision, syncRevision, topicMarker } = channelValue;
-
- curRevision = topicRevision;
- setRevision = syncRevision;
- marker = topicMarker;
- updateState({ card: cardValue, channel: channelValue });
-
if (!loaded.current) {
const topicItems = await getTopicItems(cardId, channelId);
for (let topic of topicItems) {
topics.current.set(topic.topicId, topic);
}
- updateState({ offsync: false, topics: topics.current });
+ updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
+
+ const { syncRevision, topicMarker } = channelValue;
+ curSyncRevision.current = syncRevision;
+ curTopicMarker.current = topicMarker;
loaded.current = true;
}
+ else {
+ updateState({ card: cardValue, channel: channelValue });
+ }
}
else {
console.log("failed to load conversation");
@@ -90,34 +84,37 @@ console.log("SYNCING!");
return;
}
- if (ignoreRevision || curRevision !== setRevision) {
- try {
- if (!marker) {
+ try {
+ if (!curTopicMarker.current) {
console.log("FIRST GET");
- const delta = await getTopicDelta(cardId, channelId, null, COUNT, null, null);
- await setTopicDelta(cardId, channelId, delta.topics);
- await setMarkerAndSync(cardId, channelId, delta.marker, curRevision);
- }
- if (loadMore && marker) {
+ const delta = await getTopicDelta(cardId, channelId, null, COUNT, null, null);
+ await setTopicDelta(cardId, channelId, delta.topics);
+ await setMarkerAndSync(cardId, channelId, delta.marker, topicRevision);
+ curTopicMarker.current = delta.marker;
+console.log("---", delta);
+ curSyncRevision.current = topicRevision;
+ }
+ if (loadMore && marker) {
console.log("MORE GET");
- const delta = await getTopicDelta(cardId, channelId, null, COUNT, null, marker);
- await setTopicDelta(cardId, channelId, delta.topics);
- await setTopicMarker(cardId, channelId, delta.marker);
- }
- if (ignoreRevision || curRevision !== setRevision) {
+ const delta = await getTopicDelta(cardId, channelId, null, COUNT, null, curTopicMarker.current);
+ await setTopicDelta(cardId, channelId, delta.topics);
+ await setTopicMarker(cardId, channelId, delta.marker);
+ curTopicMarker.current = delta.marker;
+ }
+ if (ignoreRevision || topicRevision !== curSyncRevision.current) {
console.log("UPDATE");
- const delta = await getTopicDelta(cardId, channelId, setRevision, null, marker, null);
- await setTopicDelta(cardId, channelId, delta.topics);
- await setSyncRevision(cardId, channelId, curRevision);
- }
- }
- catch(err) {
- console.log(err);
- updateState({ offysnc: true });
- syncing.current = false;
- return
+ const delta = await getTopicDelta(cardId, channelId, curSyncRevision.currnet, null, curTopicMarker.current, null);
+ await setTopicDelta(cardId, channelId, delta.topics);
+ await setSyncRevision(cardId, channelId, topicRevision);
+ curSyncRevision.current = topicRevision;
}
}
+ catch(err) {
+ console.log(err);
+ updateState({ offysnc: true });
+ syncing.current = false;
+ return
+ }
}
syncing.current = false;
@@ -156,11 +153,13 @@ console.log("UPDATE");
const actions = {
setConversation: async (cardId, channelId) => {
+console.log(">>> SET");
conversationId.current = { cardId, channelId };
reset.current = true;
await sync();
},
clearConversation: async () => {
+console.log(">>> CLEAR");
conversationId.current = null;
reset.current = true;
await sync();
@@ -183,6 +182,15 @@ console.log("UPDATE");
await channel.actions.removeChannel(channelId);
}
},
+ getNotifications: async () => {
+ const { cardId, channelId } = conversationId.current || {};
+ if (cardId) {
+ return await card.actions.getChannelNotifications(cardId, channelId);
+ }
+ else if (channelId) {
+ return await channel.actions.getNotifications(channelId);
+ }
+ },
setNotifications: async (notification) => {
const { cardId, channelId } = conversationId.current || {};
if (cardId) {
@@ -389,16 +397,6 @@ console.log("UPDATE");
return await channel.actions.getTopic(channelId, topicId);
}
- const getNotifications = async (notification) => {
- const { cardId, channelId } = conversationId.current || {};
- if (cardId) {
- return await card.actions.getChannelNotifications(cardId, channelId);
- }
- else if (channelId) {
- return await channel.actions.getNotifications(channelId);
- }
- }
-
const getTopicAssetUrl = (cardId, channelId, topicId, assetId) => {
if (cardId) {
return card.actions.getTopicAssetUrl(cardId, channelId, topicId, assetId);
diff --git a/app/mobile/src/context/useStoreContext.hook.js b/app/mobile/src/context/useStoreContext.hook.js
index 82a5d807..88992019 100644
--- a/app/mobile/src/context/useStoreContext.hook.js
+++ b/app/mobile/src/context/useStoreContext.hook.js
@@ -1,7 +1,7 @@
import { useEffect, useState, useRef, useContext } from 'react';
import SQLite from "react-native-sqlite-storage";
-const DATABAG_DB = 'db_v_113.db';
+const DATABAG_DB = 'db_v_114.db';
export function useStoreContext() {
const [state, setState] = useState({});
diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx
index 1cad472e..9a88c534 100644
--- a/app/mobile/src/session/Session.jsx
+++ b/app/mobile/src/session/Session.jsx
@@ -46,16 +46,23 @@ export function Session() {
const [cardId, setCardId] = useState();
const [channelId, setChannelId] = useState();
- const openConversation = async (navigation, card, channel) => {
- setCardId(card);
- setChannelId(channel);
- navigation.navigate('conversation');
- }
- const closeConversation = (navigation) => {
+
+ const setConversation = (card, channel) => {
+ (async () => {
+ conversation.actions.setConversation(card, channel);
+ setCardId(card);
+ setChannelId(channel);
+ navigation.navigate('conversation');
+ })();
+ };
+ const closeConversation = () => {
+ console.log("CLOSE CALLED!");
+ conversation.actions.clearConversation();
setCardId(null);
setChannelId(null);
navigation.popToTop();
- }
+ };
+
const openDetails = (navigation) => {
navigation.navigate('details');
}
@@ -68,7 +75,7 @@ export function Session() {
- {(props) => openDetails(props.navigation)} closeConversation={closeConversation} /> }
+ {(props) => openDetails(props.navigation)} closeConversation={closeConversation} /> }
(
@@ -147,11 +154,16 @@ export function Session() {
const [channelId, setChannelId] = useState();
const setConversation = (card, channel) => {
- setCardId(card);
- setChannelId(channel);
- setChannel(true);
+ (async () => {
+ conversation.actions.setConversation(card, channel);
+ setCardId(card);
+ setChannelId(channel);
+ setChannel(true);
+ })();
};
const closeConversation = () => {
+ console.log("CLOSE CALLED!");
+ conversation.actions.clearConversation();
setCardId(null);
setChannelId(null);
setChannel(false);
@@ -193,7 +205,7 @@ export function Session() {
{ channel && (
-
+
)}
{ !channel && (
diff --git a/app/mobile/src/session/conversation/Conversation.jsx b/app/mobile/src/session/conversation/Conversation.jsx
index 1d1a4fdb..6f226433 100644
--- a/app/mobile/src/session/conversation/Conversation.jsx
+++ b/app/mobile/src/session/conversation/Conversation.jsx
@@ -11,7 +11,7 @@ import { TopicItem } from './topicItem/TopicItem';
export function Conversation({ navigation, cardId, channelId, closeConversation, openDetails }) {
- const [ready, setReady] = useState(false);
+ const [ready, setReady] = useState(true);
const conversation = useContext(ConversationContext);
const { state, actions } = useConversation();
const ref = useRef();
@@ -57,13 +57,8 @@ export function Conversation({ navigation, cardId, channelId, closeConversation,
}, [navigation, state.subject]);
useEffect(() => {
- (async () => {
- setReady(false);
- await conversation.actions.setConversation(cardId, channelId);
- setReady(true);
- })();
- return () => { conversation.actions.clearConversation(); };
- }, [cardId, channelId]);
+ return () => { closeConversation(); };
+ }, []);
return (
diff --git a/app/mobile/src/session/conversation/Conversation.styled.js b/app/mobile/src/session/conversation/Conversation.styled.js
index 15dba9cb..c857305b 100644
--- a/app/mobile/src/session/conversation/Conversation.styled.js
+++ b/app/mobile/src/session/conversation/Conversation.styled.js
@@ -14,7 +14,6 @@ export const styles = StyleSheet.create({
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
- flexGrow: 1,
borderBottomWidth: 1,
borderColor: Colors.divider,
height: 48,
diff --git a/app/mobile/src/session/conversation/useConversation.hook.js b/app/mobile/src/session/conversation/useConversation.hook.js
index b352ce94..d5a2a578 100644
--- a/app/mobile/src/session/conversation/useConversation.hook.js
+++ b/app/mobile/src/session/conversation/useConversation.hook.js
@@ -41,6 +41,8 @@ export function useConversation() {
const filtered = sorted.filter(item => !(item.blocked === 1));
updateState({ logo, subject, topics: filtered });
+
+console.log("UPDATE TOPICS", filtered.length);
}, [conversation.state, card.state, profile.state]);