Changeset 3155d8c in Klonkt for src/services


Ignore:
Timestamp:
10/29/2026 05:50:58 PM (3 hours ago)
Author:
Bart <bart@…>
Branches:
main
Parents:
e4119c2
Message:

Inbox: ?random=1, een greep uit je geschiedenis (shaer-ewrt)

Een pagina vanaf een willekeurige post, voor 'Load random' met inbox-zero
aan. Het id is zijn echte ?before=-adres en next loopt van daar door.

Co-Authored-By: Claude Opus 5.5 <claude@…>

Location:
src/services
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    re4119c2 r3155d8c  
    5555  getTimeline, replyRowsByUri, timelineRowsByIds, getReplyMessages,
    5656  feedCursor, feedChangesSince, waitForFeedChange,
    57   conversationHeads, conversationHistory, inboxPage, messageRowsByUri,
     57  conversationHeads, conversationHistory, inboxPage, inboxRandomPage, messageRowsByUri,
    5858  readMarkers, markRead, unreadPerConversation, getDirectMessages,
    5959  isoStamp, timelineAttachments, extractEmojiTags, gateAttachments,
    … …  
    6464  getTimeline, replyRowsByUri, timelineRowsByIds, getReplyMessages,
    6565  feedCursor, feedChangesSince, waitForFeedChange,
    66   conversationHeads, conversationHistory, inboxPage, messageRowsByUri,
     66  conversationHeads, conversationHistory, inboxPage, inboxRandomPage, messageRowsByUri,
    6767  readMarkers, markRead, unreadPerConversation, getDirectMessages,
    6868  isoStamp, timelineAttachments, extractEmojiTags, gateAttachments,
    … …  
    43954395  getInteractions, getInteractionById, setInteractionBoosted, setInteractionLiked, buildReplyNote, getOutboxNote, getSentNotes, deliverReply, resolveRemoteNote, noteAudience, mayReadNote,
    43964396  listOutbox, deliverOutboxDelete, deliverOutboxUpdate, deliverDirectNote,
    4397   webfingerResolve, followActor, resolveRemoteActor, unfollowActor, handleMoveInbox, moveAccount, listFollowing, setAutoBoost, backfillFromOutbox, getTimeline, timelineRowsByIds, contentWarning, getDirectMessages, readMarkers, markRead, unreadPerConversation, messageRowsByUri, replyRowsByUri, conversationHeads, conversationHistory, inboxPage, isoStamp, timelineAttachments, timelineEmojis, timelineObjectLinks, timelineQuote, timelineEmbed, applyQuoteProps, deliverToActor, sendInteraction, voteOnPoll, voteOnRemotePoll,
     4397  webfingerResolve, followActor, resolveRemoteActor, unfollowActor, handleMoveInbox, moveAccount, listFollowing, setAutoBoost, backfillFromOutbox, getTimeline, timelineRowsByIds, contentWarning, getDirectMessages, readMarkers, markRead, unreadPerConversation, messageRowsByUri, replyRowsByUri, conversationHeads, conversationHistory, inboxPage, inboxRandomPage, isoStamp, timelineAttachments, timelineEmojis, timelineObjectLinks, timelineQuote, timelineEmbed, applyQuoteProps, deliverToActor, sendInteraction, voteOnPoll, voteOnRemotePoll,
    43984398  acceptGatedFollow, rejectGatedFollow, isWardGuardian, outboxAudience, sendFollowDecision,
    43994399  gateOutgoingFollow, performApprovedFollow, recordGuardianEvent, listGuardianEvents, GUARDIAN_EVENT_KEEP,
  • src/services/ap-timeline.js

    re4119c2 r3155d8c  
    402402}
    403403
     404/**
     405 * Een pagina vanaf een willekeurige post in je geschiedenis (shaer-ewrt).
     406 *
     407 * Het anker is een TIJDLIJNRIJ, geen willekeurige rij uit de unie: de app
     408 * toont posts in het raster, en een greep die op een stapel berichten landt
     409 * laat niets zien. Vanaf daar is het een gewone pagina over alle poten, dus
     410 * `start` is een echte cursor en `next` loopt gewoon door.
     411 *
     412 * `rnd` is er voor de toetsen.
     413 */
     414export function inboxRandomPage(slug, { limit = 60, rnd = Math.random } = {}) {
     415  try {
     416    const { n } = db.prepare('SELECT COUNT(*) AS n FROM ap_timeline WHERE slug = ?').get(slug);
     417    const k = n ? Math.min(Math.floor(rnd() * n), n - 1) : 0;
     418    if (k === 0) return { ...inboxPage(slug, { limit }), start: null };
     419    // De rij er net boven: de pagina begint direct daaronder, met het anker
     420    // als eerste post. Zelfde stempel en volgorde als de unie.
     421    const boven = db.prepare(`
     422      SELECT id AS ref, ${STEMPEL('COALESCE(published, created_at)')} AS stamp
     423        FROM ap_timeline WHERE slug = ?
     424       ORDER BY stamp DESC, ref DESC LIMIT 1 OFFSET ?`).get(slug, k - 1);
     425    const start = cursorOf(boven);
     426    return { ...inboxPage(slug, { before: start, limit }), start };
     427  } catch { return { rows: [], more: false, oldest: null, start: null }; }
     428}
     429
    404430// De kolommen die een bericht tot kaart maken. Een constante, want de
    405431// gesprekslezing haalt dezelfde rows op: twee lijsten die uiteenlopen leveren
Note: See TracChangeset for help on using the changeset viewer.