mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
support for unblocking messages
This commit is contained in:
parent
8771eba2ed
commit
a86556c993
@ -473,6 +473,14 @@ export function useCardContext() {
|
||||
const { guid } = session.current;
|
||||
await store.actions.setCardChannelTopicBlocked(guid, cardId, channelId, topicId, true);
|
||||
},
|
||||
clearChannelTopicBlocked: async (cardId, channelId, topicId) => {
|
||||
const { guid } = session.current;
|
||||
await store.actions.setCardChannelTopicBlocked(guid, cardId, channelId, topicId, false);
|
||||
},
|
||||
getChannelTopicBlocked: async () => {
|
||||
const { guid } = session.current;
|
||||
return await store.actions.getCardChannelTopicBlocked(guid);
|
||||
},
|
||||
getChannelTopicItems: async (cardId, channelId) => {
|
||||
const { guid } = session.current;
|
||||
return await store.actions.getCardChannelTopicItems(guid, cardId, channelId);
|
||||
|
@ -204,6 +204,14 @@ export function useChannelContext() {
|
||||
const { guid } = session.current;
|
||||
await store.actions.setChannelTopicBlocked(guid, channelId, topicId, true);
|
||||
},
|
||||
clearTopicBlocked: async (channelId, topicId) => {
|
||||
const { guid } = session.current;
|
||||
await store.actions.setChannelTopicBlocked(guid, channelId, topicId, false);
|
||||
},
|
||||
getTopicBlocked: async () => {
|
||||
const { guid } = session.current;
|
||||
return await store.actions.getChannelTopicBlocked(guid);
|
||||
},
|
||||
getTopicItems: async (channelId) => {
|
||||
const { guid } = session.current;
|
||||
return await store.actions.getChannelTopicItems(guid, channelId);
|
||||
|
@ -422,11 +422,25 @@ export function useConversationContext() {
|
||||
await channel.actions.setTopicBlocked(channelId, topicId);
|
||||
}
|
||||
const topic = topics.current.get(topicId);
|
||||
topic.blocked = 1;
|
||||
force.current = true;
|
||||
sync();
|
||||
if (topic) {
|
||||
topic.blocked = 1;
|
||||
force.current = true;
|
||||
sync();
|
||||
}
|
||||
}
|
||||
},
|
||||
unblockTopic: async (cardId, channelId, topicId) => {
|
||||
if (conversationId.current) {
|
||||
if (conversationId.current.cardId == cardId && conversationId.current.channelId == channelId) {
|
||||
const topic = topics.current.get(topicId);
|
||||
if (topic) {
|
||||
topic.blocked = 0;
|
||||
force.current = true;
|
||||
sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { state, actions }
|
||||
|
@ -257,7 +257,15 @@ export function useStoreContext() {
|
||||
await db.current.executeSql(`DELETE FROM channel_topic_${guid} WHERE channel_id=?`, [channelId]);
|
||||
},
|
||||
setChannelTopicBlocked: async (guid, channelId, topicId, blocked) => {
|
||||
let ret = await db.current.executeSql(`UPDATE channel_topic_${guid} set blocked=? WHERE channel_id=? and topic_id=?`, [blocked, channelId, topicId]);
|
||||
await db.current.executeSql(`UPDATE channel_topic_${guid} set blocked=? WHERE channel_id=? and topic_id=?`, [blocked, channelId, topicId]);
|
||||
},
|
||||
getChannelTopicBlocked: async (guid) => {
|
||||
const values = await getAppValues(db.current, `SELECT channel_id, topic_id, detail FROM channel_topic_${guid} WHERE blocked=?`, [1]);
|
||||
return values.map(topic => ({
|
||||
channelId: topic.channel_id,
|
||||
topicId: topic.topic_id,
|
||||
detail: decodeObject(topic.detail),
|
||||
}));
|
||||
},
|
||||
|
||||
setCardChannelItem: async (guid, cardId, channel) => {
|
||||
@ -321,7 +329,7 @@ export function useStoreContext() {
|
||||
detailRevision: topic.detail_revision,
|
||||
detail: decodeObject(topic.detail),
|
||||
}));
|
||||
},
|
||||
},
|
||||
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) values (?, ?, ?, ?, ?, ?);`, [cardId, channelId, id, revision, data.detailRevision, encodeObject(data.topicDetail)]);
|
||||
@ -335,6 +343,15 @@ export function useStoreContext() {
|
||||
setCardChannelTopicBlocked: async (guid, cardId, channelId, topicId, blocked) => {
|
||||
await db.current.executeSql(`UPDATE card_channel_topic_${guid} set blocked=? WHERE card_id=? and channel_id=? and topic_id=?`, [blocked ? 1 : 0, cardId, channelId, topicId]);
|
||||
},
|
||||
getCardChannelTopicBlocked: async (guid) => {
|
||||
const values = await getAppValues(db.current, `SELECT card_id, channel_id, topic_id, detail FROM card_channel_topic_${guid} WHERE blocked=?`, [1]);
|
||||
return values.map(topic => ({
|
||||
cardId: topic.card_id,
|
||||
channelId: topic.channel_id,
|
||||
topicId: topic.topic_id,
|
||||
detail: decodeObject(topic.detail),
|
||||
}));
|
||||
},
|
||||
}
|
||||
return { state, actions }
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import ImagePicker from 'react-native-image-crop-picker'
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { BlockedTopics } from './blockedTopics/BlockedTopics';
|
||||
import { BlockedContacts } from './blockedContacts/BlockedContacts';
|
||||
import { BlockedMessages } from './blockedMessages/BlockedMessages';
|
||||
|
||||
export function ProfileTitle(props) {
|
||||
const { state, actions } = useProfile();
|
||||
@ -149,6 +150,9 @@ export function Profile() {
|
||||
<TouchableOpacity style={styles.link} onPress={actions.showBlockedChannels}>
|
||||
<Text style={styles.linkText}>Manage Blocked Topics</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.link} onPress={actions.showBlockedMessages}>
|
||||
<Text style={styles.linkText}>Manage Blocked Messages</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.logout} onPress={logout}>
|
||||
<Ionicons name="logout" size={14} color={Colors.white} />
|
||||
<Text style={styles.logoutText}>Logout</Text>
|
||||
@ -214,6 +218,27 @@ export function Profile() {
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</Modal>
|
||||
<Modal
|
||||
animationType="fade"
|
||||
transparent={true}
|
||||
visible={state.blockedMessages}
|
||||
supportedOrientations={['portrait', 'landscape']}
|
||||
onRequestClose={actions.hideBlockedMessages}
|
||||
>
|
||||
<KeyboardAvoidingView behavior="height" style={styles.editWrapper}>
|
||||
<View style={styles.editContainer}>
|
||||
<Text style={styles.editHeader}>Blocked Messages:</Text>
|
||||
<View style={styles.editList}>
|
||||
<BlockedMessages />
|
||||
</View>
|
||||
<View style={styles.editControls}>
|
||||
<TouchableOpacity style={styles.close} onPress={actions.hideBlockedMessages}>
|
||||
<Text>Close</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</Modal>
|
||||
<Modal
|
||||
animationType="fade"
|
||||
transparent={true}
|
||||
|
@ -30,6 +30,7 @@ export function useProfile() {
|
||||
showConfirm: false,
|
||||
blockedChannels: false,
|
||||
blockedCards: false,
|
||||
blockedMessages: false,
|
||||
tabbed: null,
|
||||
disconnected: false,
|
||||
});
|
||||
@ -94,6 +95,12 @@ export function useProfile() {
|
||||
hideBlockedCards: () => {
|
||||
updateState({ blockedCards: false });
|
||||
},
|
||||
showBlockedMessages: () => {
|
||||
updateState({ blockedMessages: true });
|
||||
},
|
||||
hideBlockedMessages: () => {
|
||||
updateState({ blockedMessages: false });
|
||||
},
|
||||
showLoginEdit: () => {
|
||||
updateState({ showLoginEdit: true });
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user