diff --git a/app/mobile/src/context/useCardContext.hook.js b/app/mobile/src/context/useCardContext.hook.js
index dea0ef0f..aff1c6eb 100644
--- a/app/mobile/src/context/useCardContext.hook.js
+++ b/app/mobile/src/context/useCardContext.hook.js
@@ -473,9 +473,13 @@ export function useCardContext() {
await store.actions.setCardChannelTopicBlocked(guid, cardId, channelId, topicId, true);
},
clearTopicFlag: async (cardId, channelId, topicId) => {
- const { guid } = access.current;
+ const { guid } = access.current || {};
await store.actions.setCardChannelTopicBlocked(guid, cardId, channelId, topicId, false);
},
+ getFlaggedTopics: async () => {
+ const { guid } = access.current || {};
+ return await store.actions.getCardChannelTopicBlocked(guid);
+ },
addChannelAlert: async (cardId, channelId) => {
const { detail, profile } = (cards.current.get(cardId) || {}).card;
const node = profile?.node ? profile.node : access.current.server;
diff --git a/app/mobile/src/context/useChannelContext.hook.js b/app/mobile/src/context/useChannelContext.hook.js
index 0df0e830..f323f0e7 100644
--- a/app/mobile/src/context/useChannelContext.hook.js
+++ b/app/mobile/src/context/useChannelContext.hook.js
@@ -251,6 +251,10 @@ export function useChannelContext() {
const { guid } = access.current || {};
await store.actions.setChannelTopicBlocked(guid, channelId, topicId, 0);
},
+ getFlaggedTopics: async () => {
+ const { guid } = access.current || {};
+ return await store.actions.getChannelTopicBlocked(guid);
+ },
addChannelAlert: async (channelId) => {
const { server, guid } = access.current || {};
return await addFlag(server, guid, channelId);
diff --git a/app/mobile/src/session/conversation/topicItem/TopicItem.jsx b/app/mobile/src/session/conversation/topicItem/TopicItem.jsx
index c50a672b..8bd16c4e 100644
--- a/app/mobile/src/session/conversation/topicItem/TopicItem.jsx
+++ b/app/mobile/src/session/conversation/topicItem/TopicItem.jsx
@@ -193,11 +193,9 @@ export function TopicItem({ item, focused, focus, hosting, remove, update, block
)}
- { !state.editable && (
-
-
-
- )}
+
+
+
{ !state.editable && (
diff --git a/app/mobile/src/session/settings/Settings.jsx b/app/mobile/src/session/settings/Settings.jsx
index 544505a1..791bddf1 100644
--- a/app/mobile/src/session/settings/Settings.jsx
+++ b/app/mobile/src/session/settings/Settings.jsx
@@ -147,6 +147,17 @@ export function Settings() {
};
const BlockedMessage = ({ item }) => {
+ return (
+
+
+
+ { item.handle }
+
+ unblock(actions.unblockMessage, { cardId: item.cardId, channelId: item.channelId, topicId: item.topicId })}>
+ { state.strings.restore }
+
+
+ )
};
return (
@@ -726,11 +737,11 @@ export function Settings() {
{ state.strings.noBlockedMessages }
)}
- { state.contacts.length !== 0 && (
+ { state.messages.length !== 0 && (
item.messageId}
+ keyExtractor={item => `${item.cardId}.${item.channelId}.${item.topicId}`}
/>
)}
diff --git a/app/mobile/src/session/settings/useSettings.hook.js b/app/mobile/src/session/settings/useSettings.hook.js
index b501275c..4e6293d9 100644
--- a/app/mobile/src/session/settings/useSettings.hook.js
+++ b/app/mobile/src/session/settings/useSettings.hook.js
@@ -98,6 +98,32 @@ export function useSettings() {
}
};
+ const setTopicItem = (item) => {
+ const { cardId, channelId, topicId, detail } = item;
+ if (cardId) {
+ const contact = card.state.cards.get(cardId);
+ const { handle, node, imageSet } = contact?.card?.profile || {};
+ return {
+ cardId: cardId,
+ channelId: channelId,
+ topicId: topicId,
+ handle: `${handle} / ${node}`,
+ logo: imageSet ? card.actions.getCardImageUrl(cardId) : 'avatar',
+ created: detail?.created,
+ }
+ }
+ else {
+ const { handle, node } = profile?.state.identity || {};
+ return {
+ channelId: channelId,
+ topicId: topicId,
+ handle: `${handle} / ${node}`,
+ logo: profile?.state?.imageUrl ? profile.state.imageUrl : 'avatar',
+ created: detail?.created,
+ }
+ }
+ };
+
useEffect(() => {
const contacts = Array.from(card.state.cards.values());
const filtered = contacts.filter(contact => contact.card.blocked);
@@ -195,8 +221,20 @@ export function useSettings() {
hideBlockedTopics: () => {
updateState({ blockedTopics: false });
},
- showBlockedMessages: () => {
- updateState({ blockedMessages: true });
+ showBlockedMessages: async () => {
+ const cardMessages = await card.actions.getFlaggedTopics();
+ const channelMessages = await channel.actions.getFlaggedTopics();
+ const merged = cardMessages.map(setTopicItem).concat(channelMessages.map(setTopicItem));
+ const sortedMerge = merged.sort((a, b) => {
+ if (a.created === b.created) {
+ return 0;
+ }
+ if (a.created < b.created) {
+ return -1;
+ }
+ return 1;
+ });
+ updateState({ blockedMessages: true, messages: sortedMerge });
},
hideBlockedMessages: () => {
updateState({ blockedMessages: false });
@@ -326,6 +364,16 @@ export function useSettings() {
await channel.actions.clearChannelFlag(channelId);
}
},
+ unblockMessage: async ({ cardId, channelId, topicId }) => {
+ if (cardId) {
+ await card.actions.clearTopicFlag(cardId, channelId, topicId);
+ updateState({ messages: state.messages.filter(item => item.cardId !== cardId || item.channelId !== channelId || item.topicId !== topicId) });
+ }
+ else {
+ await channel.actions.clearTopicFlag(channelId, topicId);
+ updateState({ messages: state.messages.filter(item => item.channelId !== channelId || item.topicId !== topicId) });
+ }
+ },
};
return { state, actions };