Merge branch 'fix-reblogged-always-on' into 'main'

Fix reblogged always on problem

See merge request soapbox-pub/ditto!165
This commit is contained in:
Alex Gleason 2024-04-19 14:21:10 +00:00
commit dd3604908b
5 changed files with 13 additions and 7 deletions

View File

@ -245,7 +245,7 @@ const reblogStatusController: AppController = async (c) => {
signal: signal, signal: signal,
}); });
const status = await renderReblog(reblogEvent); const status = await renderReblog(reblogEvent, { viewerPubkey: c.get('pubkey') });
return c.json(status); return c.json(status);
}; };

View File

@ -73,7 +73,7 @@ const streamingController: AppController = (c) => {
signal: AbortSignal.timeout(1000), signal: AbortSignal.timeout(1000),
}); });
const status = await renderReblog(event); const status = await renderReblog(event, { viewerPubkey: c.get('pubkey') });
if (status) { if (status) {
send('update', status); send('update', status);
} }

View File

@ -63,7 +63,7 @@ async function renderStatuses(c: AppContext, filters: NostrFilter[]) {
const statuses = (await Promise.all(events.map((event) => { const statuses = (await Promise.all(events.map((event) => {
if (event.kind === 6) { if (event.kind === 6) {
return renderReblog(event); return renderReblog(event, { viewerPubkey: c.get('pubkey') });
} }
return renderStatus(event, { viewerPubkey: c.get('pubkey') }); return renderStatus(event, { viewerPubkey: c.get('pubkey') });
}))).filter((boolean) => boolean); }))).filter((boolean) => boolean);

View File

@ -139,7 +139,12 @@ async function hydrateRepostEvents(opts: Omit<HydrateEventOpts, 'relations'>): P
const originalPostEvent = results.find((event) => event.id === originalPostId); const originalPostEvent = results.find((event) => event.id === originalPostId);
if (!originalPostEvent) continue; if (!originalPostEvent) continue;
await hydrateEvents({ events: [originalPostEvent], storage: storage, signal: signal, relations: ['author'] }); await hydrateEvents({
events: [originalPostEvent],
storage: storage,
signal: signal,
relations: ['author', 'event_stats'],
});
event.repost = originalPostEvent; event.repost = originalPostEvent;
} }
} }

View File

@ -111,7 +111,9 @@ async function renderStatus(event: DittoEvent, opts: statusOpts): Promise<any> {
}; };
} }
async function renderReblog(event: DittoEvent) { async function renderReblog(event: DittoEvent, opts: statusOpts) {
const { viewerPubkey } = opts;
if (!event.author) return; if (!event.author) return;
const repostId = event.tags.find(([name]) => name === 'e')?.[1]; const repostId = event.tags.find(([name]) => name === 'e')?.[1];
@ -119,8 +121,7 @@ async function renderReblog(event: DittoEvent) {
if (!event.repost) return; if (!event.repost) return;
const reblog = await renderStatus(event.repost, {}); const reblog = await renderStatus(event.repost, { viewerPubkey });
reblog.reblogged = true;
return { return {
id: event.id, id: event.id,