mirror of
https://github.com/balzack/databag.git
synced 2025-04-24 18:45:23 +00:00
filtering blocked items
This commit is contained in:
parent
93b20714b3
commit
6004f86ceb
@ -28,7 +28,8 @@ export function useContacts() {
|
||||
useEffect(() => {
|
||||
const contact = app.state.session?.getContact();
|
||||
const setCards = (cards: Card[]) => {
|
||||
updateState({cards});
|
||||
const filtered = cards.filter(card => !card.blocked);
|
||||
updateState({cards: filtered});
|
||||
};
|
||||
contact.addCardListener(setCards);
|
||||
return () => {
|
||||
|
@ -187,7 +187,8 @@ export function useContent() {
|
||||
cardChannels.current.forEach(values => {
|
||||
merged.push(...values);
|
||||
});
|
||||
const sorted = merged.sort((a, b) => {
|
||||
const filtered = merged.filter(channel => !channel.blocked);
|
||||
const sorted = filtered.sort((a, b) => {
|
||||
const aUpdated = a?.lastTopic?.created;
|
||||
const bUpdated = b?.lastTopic?.created;
|
||||
if (aUpdated == bUpdated) {
|
||||
|
@ -45,7 +45,6 @@ export function Details({close, closeAll}: {close: ()=>void, closeAll: ()=>void}
|
||||
const block = () => {
|
||||
const apply = async () => {
|
||||
await actions.block();
|
||||
closeAll();
|
||||
}
|
||||
confirmAction(state.strings.blockTopic, state.strings.blockTopicPrompt, state.strings.block, setBlocking, apply);
|
||||
}
|
||||
|
@ -274,14 +274,14 @@ export function useSettings() {
|
||||
},
|
||||
loadBlockedContacts: async () => {
|
||||
const settings = app.state.session.getSettings();
|
||||
const blockedCards = await settings.getBlockedCards();
|
||||
updateState({ blockedCards });
|
||||
const blockedContacts = await settings.getBlockedCards();
|
||||
updateState({ blockedContacts });
|
||||
},
|
||||
unblockCard: async (cardId: string) => {
|
||||
unblockContact: async (cardId: string) => {
|
||||
const contact = app.state.session.getContact();
|
||||
await contact.setBlockedCard(cardId, false);
|
||||
const blockedCards = state.blockedCards.filter(blocked => blocked.cardId != cardId);
|
||||
updateState({ blockedCards });
|
||||
const blockedContactss = state.blockedContacts.filter(blocked => blocked.cardId != cardId);
|
||||
updateState({ blockedContacts });
|
||||
},
|
||||
getTimestamp: (created: number) => {
|
||||
const now = Math.floor((new Date()).getTime() / 1000)
|
||||
|
Loading…
x
Reference in New Issue
Block a user