feed: enable ignoring duplicate textnotes option
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline was successful Details

This option drops textNotes with exactly the same content after,
it was already shown 5 times.
reduce-duplicates
OFF0 2 years ago
parent 89c54ac08f
commit 0fecfc837c
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -10,7 +10,7 @@
} }
@media (orientation: portrait) { @media (orientation: portrait) {
.mbox { .mbox {
padding: 0 calc(.5 * var(--gap)); padding: 0 var(--gap-half);
} }
} }
.mbox:last-child { .mbox:last-child {

@ -187,6 +187,16 @@ button:disabled {
flex-grow: 0; flex-grow: 0;
} }
input[type="checkbox"] {
margin: 0;
}
label.checkbox {
align-items: baseline;
display: flex;
gap: var(--gap-half);
}
button#publish { button#publish {
align-self: end; align-self: end;
order: 2; order: 2;

@ -83,6 +83,15 @@
<button type="submit" name="publish" tabindex="0" disabled>publish</button> <button type="submit" name="publish" tabindex="0" disabled>publish</button>
</div> </div>
</form> </form>
<form action="#" name="options">
<label class="checkbox" for="duplicates">
<input type="checkbox" name="dropDuplicate" id="duplicates">
<span>
drop duplicate events<br>
<small>ignore events that have already been rendered 5&nbsp;times</small>
</span>
</label>
</form>
<form action="#" name="settings" autocomplete="new-password"> <form action="#" name="settings" autocomplete="new-password">
<label for="pubkey">public-key</label> <label for="pubkey">public-key</label>
<input type="text" id="pubkey" autocomplete="off"> <input type="text" id="pubkey" autocomplete="off">

@ -14,6 +14,7 @@
--focus-outline: var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color); --focus-outline: var(--focus-outline-width) var(--focus-outline-style) var(--focus-outline-color);
--font-small: 1.2rem; --font-small: 1.2rem;
--gap: 2.4rem; --gap: 2.4rem;
--gap-half: 1.2rem;
} }
::selection { ::selection {

@ -259,7 +259,29 @@ const textNoteList = []; // could use indexDB
const eventRelayMap = {}; // eventId: [relay1, relay2] const eventRelayMap = {}; // eventId: [relay1, relay2]
const hasEventTag = tag => tag[0] === 'e'; const hasEventTag = tag => tag[0] === 'e';
const dropDuplicateToggle = document.querySelector('#duplicates');
let dropDuplicate = JSON.parse(localStorage.getItem('filter_duplicates')) ?? true;
dropDuplicateToggle.addEventListener('click', (e) => {
localStorage.setItem('filter_duplicates', e.target.checked);
dropDuplicate = e.target.checked;
});
dropDuplicateToggle.checked = dropDuplicate;
function isValidNote(evt) {
if (dropDuplicate) {
const similarEvents = textNoteList.filter(({content}) => content === evt.content);
if (similarEvents?.length >= 5) {
console.info(`DROP event ${evt.id} already got ${similarEvents.length}`, similarEvents);
return false;
}
}
return true;
}
function handleTextNote(evt, relay) { function handleTextNote(evt, relay) {
if (!isValidNote(evt)) {
return;
}
if (eventRelayMap[evt.id]) { if (eventRelayMap[evt.id]) {
eventRelayMap[evt.id] = [relay, ...(eventRelayMap[evt.id])]; eventRelayMap[evt.id] = [relay, ...(eventRelayMap[evt.id])];
} else { } else {

@ -45,7 +45,7 @@ input[type="radio"]:checked + label {
.tab-content { .tab-content {
max-width: 96ch; max-width: 96ch;
min-height: 200px; min-height: 200px;
padding: calc(.5 * var(--gap)) 0 100px 0; padding: var(--gap-half) 0 100px 0;
} }
.tabbed { .tabbed {
align-items: start; align-items: start;

Loading…
Cancel
Save