From 16f829d6a5ac0f7e4990c73ebd464b92b3ea92a6 Mon Sep 17 00:00:00 2001 From: balzack Date: Wed, 1 Mar 2023 16:56:15 -0800 Subject: [PATCH] fixing topic load --- app/mobile/src/context/useConversationContext.hook.js | 2 ++ app/mobile/src/context/useStoreContext.hook.js | 8 ++++---- app/mobile/src/session/conversation/Conversation.jsx | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/mobile/src/context/useConversationContext.hook.js b/app/mobile/src/context/useConversationContext.hook.js index a706dee2..719c0488 100644 --- a/app/mobile/src/context/useConversationContext.hook.js +++ b/app/mobile/src/context/useConversationContext.hook.js @@ -126,11 +126,13 @@ export function useConversationContext() { if (entry.data) { if (entry.data.detail) { const item = mapTopicEntry(entry); + setTopicItem(cardId, channelId, item); topics.current.set(item.topicId, item); } else { const topic = await getTopic(cardId, channelId, entry.id); const item = mapTopicEntry(entry); + setTopicItem(cardId, channelId, item); topics.current.set(item.topicId, item); } } diff --git a/app/mobile/src/context/useStoreContext.hook.js b/app/mobile/src/context/useStoreContext.hook.js index 555376ed..82a5d807 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_110.db'; +const DATABAG_DB = 'db_v_113.db'; export function useStoreContext() { const [state, setState] = useState({}); @@ -239,7 +239,7 @@ export function useStoreContext() { }, setChannelTopicItem: async (guid, channelId, topic) => { const { topicId, revision, detailRevision, detail } = topic; - await db.current.executeSql(`INSERT OR REPLACE INTO channel_topic_${guid} (channel_id, topic_id, revision, detail_revision, blocked detail, unsealed_detail) values (?, ?, ?, ?, false, ?, null);`, [channelId, topicId, revision, detailRevision, encodeObject(detail)]); + await db.current.executeSql(`INSERT OR REPLACE INTO channel_topic_${guid} (channel_id, topic_id, revision, detail_revision, blocked, detail, unsealed_detail) values (?, ?, ?, ?, false, ?, null);`, [channelId, topicId, revision, detailRevision, encodeObject(detail)]); }, setChannelTopicItemUnsealedDetail: async (guid, channelId, topicId, revision, unsealed) => { await db.current.executeSql(`UPDATE channel_topic_${guid} set unsealed_detail=? where detail_revision=? AND channel_id=? AND topic_id=?`, [encodeObject(unsealed), revision, channelId, topicId]); @@ -329,8 +329,8 @@ export function useStoreContext() { })); }, setCardChannelTopicItem: async (guid, cardId, channelId, topic) => { - const { id, revision, data } = topic; - await db.current.executeSql(`INSERT OR REPLACE INTO card_channel_topic_${guid} (card_id, channel_id, topic_id, revision, detail_revision, detail, unsealed_detail) values (?, ?, ?, ?, ?, ?, null);`, [cardId, channelId, id, revision, data.detailRevision, encodeObject(data.topicDetail)]); + const { topicId, revision, detailRevision, detail } = topic; + await db.current.executeSql(`INSERT OR REPLACE INTO card_channel_topic_${guid} (card_id, channel_id, topic_id, revision, detail_revision, detail, unsealed_detail) values (?, ?, ?, ?, ?, ?, null);`, [cardId, channelId, topicId, revision, detailRevision, encodeObject(detail)]); }, setCardChannelTopicItemUnsealedDetail: async (guid, cardId, channelId, topicId, revision, unsealed) => { await db.current.executeSql(`UPDATE card_channel_topic_${guid} set unsealed_detail=? where detail_revision=? AND card_id=? AND channel_id=? AND topic_id=?`, [encodeObject(unsealed), revision, cardId, channelId, topicId]); diff --git a/app/mobile/src/session/conversation/Conversation.jsx b/app/mobile/src/session/conversation/Conversation.jsx index f85c6468..b58926d6 100644 --- a/app/mobile/src/session/conversation/Conversation.jsx +++ b/app/mobile/src/session/conversation/Conversation.jsx @@ -19,7 +19,7 @@ export function Conversation({ navigation, cardId, channelId, closeConversation, navigation.setOptions({ headerTitle: () => ( - { state.subject } + { state.subject } ), headerRight: () => (