From 0941a26ab449495faf96edc3c0e134083fada9dd Mon Sep 17 00:00:00 2001 From: OFF0 Date: Sun, 15 Jan 2023 09:42:30 +0100 Subject: [PATCH] note: support republishing a note to all connected relays while testing duplicated relies the note with the funny replies was only available on damus which seemed to be under heavy load. added a republish button to be able to move the note to our relay for testing purpose. republishing should probably be more finetuned to be able to publish to individual relays, but that requires relay management first. hiding this feature for the moment. --- src/main.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.js b/src/main.js index 59062e3..9af19da 100644 --- a/src/main.js +++ b/src/main.js @@ -229,6 +229,10 @@ document.body.addEventListener('click', (e) => { hideNewMessage(true); return; } + if (button && button.name === 'republish') { + republish(id); + return; + } const username = e.target.closest('.mbox-username') if (username) { history.pushState({author: pubkey}, '', `/${pubkey}`); @@ -255,6 +259,18 @@ document.body.addEventListener('click', (e) => { // } }); +function republish(id) { + const note = textNoteList.find(note => note.id === id) || replyList.find(note => note.id === id); + pool.publish(note, (status, url) => { + if (status === 0) { + console.info(`publish request sent to ${url}`); + } + if (status === 1) { + console.info(`event published by ${url}`); + } + }).catch(console.error); +} + const textNoteList = []; // could use indexDB const eventRelayMap = {}; // eventId: [relay1, relay2] const hasEventTag = tag => tag[0] === 'e'; @@ -455,6 +471,9 @@ function createTextNote(evt, relay) { }), elem('small', {data: {reactions: ''}}, hasReactions ? reactionMap[evt.id].length : ''), ]), + // elem('button', {className: 'btn-inline', name: 'republish'}, [ + // elem('small', {}, 'republish') + // ]), ]), // replies[0] ? elem('div', {className: 'mobx-replies'}, replyFeed.reverse()) : '', ]); -- 2.46.2