this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

negate labels

alice 4afaa654 c1dbdbaf

+14 -8
+14 -8
src/label.ts
··· 50 50 .all(did); 51 51 console.log(`Found ${query.length} existing labels for ${did}`); 52 52 53 - const currentLabel = query.find( 54 - (label) => !label.neg && HOUSES.includes(label.val) 55 - ); 56 - console.log(`Current house label: ${currentLabel ? currentLabel.val : 'None'}`); 53 + const labels = query.reduce((set, label) => { 54 + if (!label.neg) set.add(label.val); 55 + else set.delete(label.val); 56 + return set; 57 + }, new Set<string>()); 58 + 59 + // const currentLabel = query.find( 60 + // (label) => !label.neg && HOUSES.includes(label.val) 61 + // ); 62 + // console.log(`Current house label: ${currentLabel ? currentLabel.val : 'None'}`); 57 63 58 64 if (rkey.includes(DELETE)) { 59 65 console.log(`Deleting label for ${did}`); 60 - if (currentLabel) { 66 + if (labels.size > 0) { 61 67 await server 62 - .createLabels({ uri: did }, { negate: [currentLabel.val] }) 68 + .createLabels({ uri: did }, { negate: [...labels] }) 63 69 .catch((err) => console.error(`Error deleting label: ${err}`)) 64 70 .then(() => console.log(`Deleted label for ${did}`)); 65 71 } else { 66 72 console.log(`No label to delete for ${did}`); 67 73 } 68 74 } else { 69 - if (currentLabel) { 70 - console.log(`${did} already has a house: ${currentLabel.val}`); 75 + if (labels.size > 0) { 76 + console.log(`${did} already has a house: ${[...labels].join(', ')}`); 71 77 return; 72 78 } 73 79