Changeset 9d34855 in Klonkt for src/routes/posts.js


Ignore:
Timestamp:
06/26/2026 11:50:14 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
0a75356
Parents:
c7ecaf9
Message:

fix(news): feed like is a toggle too (like/unlike), like boost

The feed star was fire-and-forget with no state. Now ap_timeline.liked remembers it,
the star shows an 'on' state, and a second click retracts via /news/unlike (Undo Like)
— mirroring the existing boost/unboost toggle. markLiked/unmarkLiked added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/posts.js

    rc7ecaf9 r9d34855  
    695695router.post('/news/like', requireSiteManager, async (req, res) => {
    696696  const site = res.locals.site;
    697   if (site) { try { await ActivityPubService.sendInteraction(site, 'like', (req.body.note || '').toString(), (req.body.author || '').toString()); } catch (e) { /* ignore */ } }
     697  const note = (req.body.note || '').toString();
     698  if (site && note) {
     699    try { await ActivityPubService.sendInteraction(site, 'like', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ }
     700    ActivityPubService.markLiked(site.slug, note);
     701  }
    698702  res.redirect('/news?success=' + encodeURIComponent('Geliket ⭐'));
     703});
     704
     705router.post('/news/unlike', requireSiteManager, async (req, res) => {
     706  const site = res.locals.site;
     707  const note = (req.body.note || '').toString();
     708  if (site && note) {
     709    try { await ActivityPubService.sendInteraction(site, 'unlike', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ }
     710    ActivityPubService.unmarkLiked(site.slug, note);
     711  }
     712  res.redirect('/news?success=' + encodeURIComponent('Like ingetrokken'));
    699713});
    700714
Note: See TracChangeset for help on using the changeset viewer.