diff --git a/app/mobile/src/context/useCardContext.hook.js b/app/mobile/src/context/useCardContext.hook.js
index 5c567c53..021bcc6f 100644
--- a/app/mobile/src/context/useCardContext.hook.js
+++ b/app/mobile/src/context/useCardContext.hook.js
@@ -361,7 +361,7 @@ export function useCardContext() {
return await setCardCloseMessage(server, message);
},
getCardImageUrl: (cardId) => {
- const { profileRevision } = cards.current.get(cardId)?.card || { };
+ const { profileRevision } = cards.current.get(cardId)?.card || {};
const { server, token } = access.current;
return getCardImageUrl(server, token, cardId, profileRevision);
},
@@ -371,17 +371,17 @@ export function useCardContext() {
return await removeContactChannel(profile?.node, cardToken, channelId);
},
addTopic: async (cardId, channelId, type, message, files) => {
- const { detail, profile } = cards.current.get(cardId) || {};
+ const { detail, profile } = cards.current.get(cardId)?.card || {};
const cardToken = `${profile?.guid}.${detail?.token}`;
const node = profile?.node;
if (files?.length > 0) {
- const topicId = await addContactChannelTopic(node, token, channelId, null, null, null);
- upload.actions.addContactTopic(node, token, cardId, channelId, topicId, files, async (assets) => {
+ const topicId = await addContactChannelTopic(node, cardToken, channelId, null, null, null);
+ upload.actions.addContactTopic(node, cardToken, cardId, channelId, topicId, files, async (assets) => {
const subject = message(assets);
- await setContactChannelTopicSubject(node, token, channelId, topicId, type, subject);
+ await setContactChannelTopicSubject(node, cardToken, channelId, topicId, type, subject);
}, async () => {
try {
- await removeContactChannelTopic(node, token, channelId, topicId);
+ await removeContactChannelTopic(node, cardToken, channelId, topicId);
}
catch (err) {
console.log(err);
@@ -390,7 +390,7 @@ export function useCardContext() {
}
else {
const subject = message([]);
- await addContactChannelTopic(node, token, channelId, type, subject, []);
+ await addContactChannelTopic(node, cardToken, channelId, type, subject, []);
}
},
removeTopic: async (cardId, channelId, topicId) => {
diff --git a/app/mobile/src/context/useConversationContext.hook.js b/app/mobile/src/context/useConversationContext.hook.js
index 5bd2d6ce..c4d3da0b 100644
--- a/app/mobile/src/context/useConversationContext.hook.js
+++ b/app/mobile/src/context/useConversationContext.hook.js
@@ -61,7 +61,6 @@ export function useConversationContext() {
const cardValue = cardId ? card.state.cards.get(cardId) : null;
const channelValue = cardId ? cardValue?.channels.get(channelId) : channel.state.channels.get(channelId);
const { topicRevision } = channelValue || {};
- let setChannel = false;
if (channelValue) {
if (!loaded.current) {
@@ -76,9 +75,6 @@ export function useConversationContext() {
curTopicMarker.current = topicMarker;
loaded.current = true;
}
- else {
- setChannel = true;
- }
}
else {
console.log("failed to load conversation");
@@ -93,25 +89,20 @@ export function useConversationContext() {
await setMarkerAndSync(cardId, channelId, delta.marker, topicRevision);
curTopicMarker.current = delta.marker;
curSyncRevision.current = topicRevision;
- updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
}
- else if (loadMore && marker) {
+ if (loadMore && marker) {
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;
- updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
}
- else if (ignoreRevision || topicRevision !== curSyncRevision.current) {
+ if (ignoreRevision || topicRevision > curSyncRevision.current) {
const delta = await getTopicDelta(cardId, channelId, curSyncRevision.current, null, curTopicMarker.current, null);
await setTopicDelta(cardId, channelId, delta.topics);
- await setSyncRevision(cardId, channelId, 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 });
+ await setSyncRevision(cardId, channelId, delta.revision);
+ curSyncRevision.current = delta.revision;
}
+ updateState({ offsync: false, topics: topics.current, card: cardValue, channel: channelValue });
}
catch(err) {
console.log(err);
diff --git a/app/mobile/src/context/useStoreContext.hook.js b/app/mobile/src/context/useStoreContext.hook.js
index a14c199d..5c62e707 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_115.db';
+const DATABAG_DB = 'db_v_116.db';
export function useStoreContext() {
const [state, setState] = useState({});
diff --git a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx
index 0e335847..5d5a4a0a 100644
--- a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx
+++ b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx
@@ -159,7 +159,7 @@ export function AddTopic({ sealed, sealKey }) {
{ state.busy && (
-
+
)}
{ !state.busy && (state.message || state.assets.length > 0) && (
diff --git a/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js b/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js
index 0b65e0e5..596cfebf 100644
--- a/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js
+++ b/app/mobile/src/session/conversation/addTopic/useAddTopic.hook.js
@@ -2,6 +2,8 @@ import { useState, useRef, useEffect, useContext } from 'react';
import { ConversationContext } from 'context/ConversationContext';
import { Image } from 'react-native';
import Colors from 'constants/Colors';
+import { getChannelSeals, getContentKey, encryptTopicSubject } from 'context/sealUtil';
+import { AccountContext } from 'context/AccountContext';
export function useAddTopic(sealed, sealKey) {
@@ -23,6 +25,7 @@ export function useAddTopic(sealed, sealKey) {
const assetId = useRef(0);
const conversation = useContext(ConversationContext);
+ const account = useContext(AccountContext);
const updateState = (value) => {
setState((s) => ({ ...s, ...value }));
@@ -107,17 +110,43 @@ export function useAddTopic(sealed, sealKey) {
if (!state.busy) {
try {
updateState({ busy: true });
- let message = {
- text: state.message,
- textColor: state.colorSet ? state.color : null,
- textSize: state.sizeSet ? state.size : null,
+
+ let contentKey;
+ const type = conversation.state.channel?.detail?.dataType === 'superbasic' ? 'superbasictopic' : 'sealedtopic';
+ if (type === 'sealedtopic') {
+ const channelDetail = conversation.state.channel?.detail;
+ const seals = getChannelSeals(channelDetail?.data);
+ const sealKey = account.state.sealKey;
+ contentKey = await getContentKey(seals, sealKey);
+ }
+ const assemble = (assets) => {
+ if (type === 'superbasictopic') {
+ if (assets?.length) {
+ return {
+ assets,
+ text: state.message,
+ textColor: state.colorSet ? state.color : null,
+ textSize: state.sizeSet ? state.size : null,
+ }
+ }
+ else {
+ return {
+ text: state.message,
+ textColor: state.colorSet ? state.color : null,
+ textSize: state.sizeSet ? state.size : null,
+ }
+ }
+ }
+ else {
+ const message = {
+ text: state.message,
+ textColor: state.textColorSet ? state.textColor : null,
+ textSize: state.textSizeSet ? state.textSize : null,
+ }
+ return encryptTopicSubject({ message }, contentKey);
+ }
};
- if (sealed) {
- await conversation.actions.addSealedTopic(message, sealKey);
- }
- else {
- await conversation.actions.addTopic(message, state.assets);
- }
+ await conversation.actions.addTopic(type, assemble, state.assets);
updateState({ busy: false, assets: [], message: null,
size: 'medium', sizeSet: false, textSize: 14,
color: Colors.text, colorSet: false,
diff --git a/app/mobile/src/session/details/Details.jsx b/app/mobile/src/session/details/Details.jsx
index 7c44be7a..c3fc5997 100644
--- a/app/mobile/src/session/details/Details.jsx
+++ b/app/mobile/src/session/details/Details.jsx
@@ -205,7 +205,9 @@ export function Details({ channel, clearConversation }) {
setNotifications(!state.notification)} activeOpacity={1}>
Enable Notifications
-
+ { state.notification != null && (
+
+ )}
diff --git a/app/mobile/src/session/details/Details.styled.js b/app/mobile/src/session/details/Details.styled.js
index 9ea9a773..ab462eda 100644
--- a/app/mobile/src/session/details/Details.styled.js
+++ b/app/mobile/src/session/details/Details.styled.js
@@ -14,6 +14,7 @@ export const styles = StyleSheet.create({
paddingTop: 16,
flexShrink: 1,
minWidth: 0,
+ maxWidth: '80%',
},
info: {
paddingLeft: 8,
diff --git a/app/mobile/src/session/details/useDetails.hook.js b/app/mobile/src/session/details/useDetails.hook.js
index 660e75b7..672b0752 100644
--- a/app/mobile/src/session/details/useDetails.hook.js
+++ b/app/mobile/src/session/details/useDetails.hook.js
@@ -29,6 +29,7 @@ export function useDetails() {
deleteBusy: false,
blockBusy: false,
unknown: 0,
+ notification: null,
});
const card = useContext(CardContext);