mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
unblocking topics in refactored settings screen
This commit is contained in:
parent
b1557bf204
commit
0d04c26b2a
@ -465,7 +465,7 @@ export function useCardContext() {
|
||||
},
|
||||
clearChannelFlag: async (cardId, channelId) => {
|
||||
const { guid } = access.current || {};
|
||||
await store.actions.setCardChannelItemBlocked(guid, cardId, channelId);
|
||||
await store.actions.clearCardChannelItemBlocked(guid, cardId, channelId);
|
||||
setCardChannelField(cardId, channelId, 'blocked', false);
|
||||
},
|
||||
setTopicFlag: async (cardId, channelId, topicId) => {
|
||||
|
@ -125,7 +125,7 @@ export function Settings() {
|
||||
<Text style={styles.name} numberOfLines={1} ellipsizeMode={'tail'}>{ item.name }</Text>
|
||||
<Text style={styles.handle} numberOfLines={1} ellipsizeMode={'tail'}>{ item.handle }</Text>
|
||||
</View>
|
||||
<TouchableOpacity onPress={() => unblock(actions.unblockContact, item.cardId)}>
|
||||
<TouchableOpacity onPress={() => unblock(actions.unblockContact, { cardId: item.cardId })}>
|
||||
<Text style={styles.restore}>{ state.strings.restore }</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
@ -139,7 +139,7 @@ export function Settings() {
|
||||
<View style={styles.detail}>
|
||||
<Text style={styles.name} numberOfLines={1} ellipsizeMode={'tail'}>{ item.subject }</Text>
|
||||
</View>
|
||||
<TouchableOpacity onPress={() => unblock(actions.unblockTopic, item.cardId, item.channelId)}>
|
||||
<TouchableOpacity onPress={() => unblock(actions.unblockTopic, { cardId: item.cardId, channelId: item.channelId })}>
|
||||
<Text style={styles.restore}>{ state.strings.restore }</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
@ -691,7 +691,7 @@ export function Settings() {
|
||||
<FlatList
|
||||
data={state.topics}
|
||||
renderItem={BlockedTopic}
|
||||
keyExtractor={item => item.topicId}
|
||||
keyExtractor={item => `${item.cardId}.${item.channelId}`}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
|
@ -88,9 +88,9 @@ export function useSettings() {
|
||||
|
||||
const setChannelItem = (item) => {
|
||||
const profileGuid = profile.state?.identity?.guid;
|
||||
const { logo, subject } = getChannelSubjectLogo(null, profileGuid, item, card.state.cards, card.actions.getCardImageUrl);
|
||||
const { logo, subject } = getChannelSubjectLogo(item.cardId, profileGuid, item, card.state.cards, card.actions.getCardImageUrl);
|
||||
return {
|
||||
cardId: null,
|
||||
cardId: item.cardId,
|
||||
channelId: item.channelId,
|
||||
created: item.detail.created,
|
||||
logo: logo,
|
||||
@ -112,10 +112,10 @@ export function useSettings() {
|
||||
});
|
||||
updateState({ contacts: sorted });
|
||||
|
||||
contacts.current = [];
|
||||
cardChannels.current = [];
|
||||
contacts.forEach(contact => {
|
||||
const filtered = Array.from(contact.channels.values()).filter(topic => topic.blocked);
|
||||
const mapped = filtered.map(setChannelItem).map(item => ({ ...item, cardId: contact.card.cardId }));
|
||||
const mapped = filtered.map(item => setChannelItem({ ...item, cardId: contact.card.cardId }));
|
||||
cardChannels.current = cardChannels.current.concat(mapped);
|
||||
});
|
||||
const merged = cardChannels.current.concat(channels.current);
|
||||
@ -315,9 +315,17 @@ export function useSettings() {
|
||||
removeKey: async () => {
|
||||
await removeKey();
|
||||
},
|
||||
unblockContact: async (cardId) => {
|
||||
unblockContact: async ({ cardId }) => {
|
||||
await card.actions.clearCardFlag(cardId);
|
||||
},
|
||||
unblockTopic: async ({ cardId, channelId }) => {
|
||||
if (cardId) {
|
||||
await card.actions.clearChannelFlag(cardId, channelId);
|
||||
}
|
||||
else {
|
||||
await channel.actions.clearChannelFlag(channelId);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return { state, actions };
|
||||
|
Loading…
Reference in New Issue
Block a user