diff --git a/app/mobile/src/context/useCardContext.hook.js b/app/mobile/src/context/useCardContext.hook.js
index f09b6c44..0e1b252e 100644
--- a/app/mobile/src/context/useCardContext.hook.js
+++ b/app/mobile/src/context/useCardContext.hook.js
@@ -327,7 +327,7 @@ export function useCardContext() {
await store.actions.setCardChannelItemSummary(guid, cardId, channel.id, topicRevision, summary);
setCardChannelSummary(cardId, channel.id, summary, topicRevision);
}
- await store.actions.setCardChannelItemRevision(guid, cardId, channel.revision);
+ await store.actions.setCardChannelItemRevision(guid, cardId, channel.id, channel.revision);
setCardChannelRevision(cardId, channel.id, channel.revision);
}
}
@@ -466,7 +466,13 @@ export function useCardContext() {
},
addChannelTopic: async (cardId, channelId, message, assets) => {
const { detail, profile } = getCard(cardId);
- return await addChannelTopic(profile.node, `${profile.guid}.${detail.token}`, channelId, message, assets);
+ if (assets?.length > 0) {
+ console.log("UPLOAD");
+ }
+ else {
+ await addContactChannelTopic(profile.node, `${profile.guid}.${detail.token}`, channelId, message, []);
+ // sync channel
+ }
},
setChannelTopicSubject: async (cardId, channelId, topicId, data) => {
const { detail, profile } = getCard(cardId);
diff --git a/app/mobile/src/context/useChannelContext.hook.js b/app/mobile/src/context/useChannelContext.hook.js
index d82ec815..0eca0782 100644
--- a/app/mobile/src/context/useChannelContext.hook.js
+++ b/app/mobile/src/context/useChannelContext.hook.js
@@ -210,7 +210,13 @@ export function useChannelContext() {
},
addTopic: async (channelId, message, assets) => {
const { server, appToken } = session.current;
- return await addChannelTopic(server, appToken, channelId, message, assets);
+ if (assets?.length) {
+ console.log("UPLOAD");
+ }
+ else {
+ await addChannelTopic(server, appToken, channelId, message, []);
+ //sync channels
+ }
},
setTopicSubject: async (channelId, topicId, data) => {
const { server, appToken } = session.current;
diff --git a/app/mobile/src/context/useConversationContext.hook.js b/app/mobile/src/context/useConversationContext.hook.js
index 6438f59e..3ddfb8ed 100644
--- a/app/mobile/src/context/useConversationContext.hook.js
+++ b/app/mobile/src/context/useConversationContext.hook.js
@@ -18,6 +18,7 @@ export function useConversationContext() {
const profile = useContext(ProfileContext);
const topics = useRef(null);
const revision = useRef(0);
+ const force = useRef(false);
const detailRevision = useRef(0);
const syncing = useRef(false);
const conversationId = useRef(null);
@@ -107,7 +108,7 @@ export function useConversationContext() {
if (conversationId.current) {
const { cardId, channelId } = conversationId.current;
const channelItem = getChannel(cardId, channelId);
- if (channelItem && (channelItem.revision !== revision.current)) {
+ if (channelItem && (channelItem.revision !== revision.current || force.current)) {
syncing.current = true;
try {
@@ -129,7 +130,8 @@ export function useConversationContext() {
}
// sync from server
- if (channelItem.topicRevision !== channelItem.syncRevision) {
+ if (channelItem.topicRevision != channelItem.syncRevision || force.current) {
+ force.current = false;
const res = await getTopics(cardId, channelId, channelItem.syncRevision)
for (const topic of res.topics) {
if (!topic.data) {
@@ -147,7 +149,7 @@ export function useConversationContext() {
topics.current.set(id, { topicId: id, revision: revision, detailRevision: topic.data.detailRevision, detail: topic.data.topicDetail });
}
}
- await setSyncRevision(cardId, channelId, channelItem.topicRevision);
+ await setSyncRevision(cardId, channelId, res.revision);
}
// update revision
@@ -299,6 +301,19 @@ export function useConversationContext() {
}
return null;
},
+ addTopic: async (message, files) => {
+ if (conversationId.current) {
+ const { cardId, channelId } = conversationId.current;
+ if (cardId) {
+ await card.actions.addChannelTopic(cardId, channelId, message, files);
+ }
+ else {
+ await channel.actions.addTopic(channelId, message, files);
+ }
+ force.current = true;
+ sync();
+ }
+ },
}
return { state, actions }
diff --git a/app/mobile/src/context/useStoreContext.hook.js b/app/mobile/src/context/useStoreContext.hook.js
index d1b8e1fc..da6be906 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 = 'databag_v037.db';
+const DATABAG_DB = 'databag_v038.db';
export function useStoreContext() {
const [state, setState] = useState({});
diff --git a/app/mobile/src/session/conversation/Conversation.jsx b/app/mobile/src/session/conversation/Conversation.jsx
index d4ad609a..ec170ad4 100644
--- a/app/mobile/src/session/conversation/Conversation.jsx
+++ b/app/mobile/src/session/conversation/Conversation.jsx
@@ -72,7 +72,7 @@ export function ConversationBody() {
{ !state.latched && (
-
+
)}
diff --git a/app/mobile/src/session/conversation/Conversation.styled.js b/app/mobile/src/session/conversation/Conversation.styled.js
index 944848ea..56531b1b 100644
--- a/app/mobile/src/session/conversation/Conversation.styled.js
+++ b/app/mobile/src/session/conversation/Conversation.styled.js
@@ -80,7 +80,7 @@ export const styles = StyleSheet.create({
},
latchbar: {
position: 'absolute',
- top: -16,
+ top: -26,
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
@@ -89,6 +89,9 @@ export const styles = StyleSheet.create({
latch: {
backgroundColor: Colors.formBackground,
borderRadius: 12,
+ borderWidth: 1,
+ padding: 4,
+ borderColor: Colors.primary,
},
})
diff --git a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx
index ee4988f6..b7d36d85 100644
--- a/app/mobile/src/session/conversation/addTopic/AddTopic.jsx
+++ b/app/mobile/src/session/conversation/addTopic/AddTopic.jsx
@@ -1,4 +1,4 @@
-import { Modal, Image, FlatList, TextInput, Alert, View, TouchableOpacity, Text, } from 'react-native';
+import { ActivityIndicator, Modal, Image, FlatList, TextInput, Alert, View, TouchableOpacity, Text, } from 'react-native';
import { useState, useRef } from 'react';
import { useAddTopic } from './useAddTopic.hook';
import { styles } from './AddTopic.styled';
@@ -28,6 +28,19 @@ export function AddTopic() {
}
}
+ const sendMessage = async () => {
+ try {
+ await actions.addTopic();
+ }
+ catch (err) {
+ console.log(err);
+ Alert.alert(
+ 'Failed to Send Message',
+ 'Please try again.',
+ )
+ }
+ }
+
const addVideo = async () => {
try {
const full = await ImagePicker.openPicker({ mediaType: 'video' });
@@ -122,8 +135,16 @@ export function AddTopic() {
-
-
+
+ { state.busy && (
+
+ )}
+ { !state.busy && (state.message || state.assets.length > 0) && (
+
+ )}
+ { !state.busy && !(state.message || state.assets.length > 0) && (
+
+ )}
{
- updateState({ size });
+ updateState({ size, sizeSet: true });
},
setFontColor: (color) => {
- updateState({ color });
+ updateState({ color, colorSet: true });
+ },
+ addTopic: async () => {
+ if (!state.busy) {
+ try {
+ updateState({ busy: true });
+ let message = {
+ text: state.message,
+ textColor: state.colorSet ? state.color : null,
+ textSize: state.sizeSet ? state.size : null,
+ };
+ await conversation.actions.addTopic(message, state.assets);
+ updateState({ busy: false, assets: [], message: null,
+ size: 'medium', sizeSet: false,
+ color: Colors.text, colorSet: false,
+ });
+ }
+ catch(err) {
+ console.log(err);
+ updateState({ busy: false });
+ throw new Error("failed to add message");
+ }
+ }
},
};