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