aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/features/messages.js58
-rw-r--r--src/style.css14
2 files changed, 72 insertions, 0 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 6875856..6b3ff4c 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -5420,6 +5420,7 @@ export function messagesFeature(ctx) {
lastScrollAt = Date.now();
if (!ui.profilePk && (!(ui.chatOpen && ui.msgView === 'feed') || ui.noteThread)) return;
windowScrolled(ui.profilePk ? notesCache.get(ui.profilePk) : feed);
+ scrollWhen(ui.profilePk ? notesCache.get(ui.profilePk) : feed);
// Starting to scroll up dismisses the notice: the reader is already
// heading toward the new posts. Keyed rows keep their positions.
// Upward only: holding the page still as posts go in above scrolls it
@@ -5442,6 +5443,63 @@ export function messagesFeature(ctx) {
else loadOlderFeed().catch(() => {});
}, { passive: true });
}
+ // How far back you've scrolled: while the feed (or a profile's posts)
+ // moves, a small chip under the top bar says when the post at the top of
+ // the screen was written, and fades a moment after the scrolling stops
+ // ("some sort of little counter that shows the date and time of posts
+ // where I'm in the timeline", Adam, 2026-11-17). Painted straight into the
+ // DOM, outside render(): it changes every frame of a fling.
+ let whenEl = null, whenRaf = 0, whenHide = 0, whenIdx = { list: null, map: null };
+ function whenLabel(sec) {
+ const d = new Date(sec * 1000), now = new Date();
+ const time = d.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
+ const date = d.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric', ...(d.getFullYear() !== now.getFullYear() ? { year: 'numeric' } : {}) });
+ const ago = Math.max(0, (now - d) / 1000);
+ let rel = '';
+ try {
+ const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: 'auto' });
+ rel = ago < 3600 ? rtf.format(-Math.max(1, Math.round(ago / 60)), 'minute')
+ : ago < 86400 ? rtf.format(-Math.round(ago / 3600), 'hour')
+ : ago < 86400 * 60 ? rtf.format(-Math.round(ago / 86400), 'day')
+ : ago < 86400 * 730 ? rtf.format(-Math.round(ago / (86400 * 30.4)), 'month')
+ : rtf.format(-Math.round(ago / (86400 * 365)), 'year');
+ } catch {}
+ const today = d.toDateString() === now.toDateString();
+ return (today ? time : date + ' · ' + time) + (rel ? ' · ' + rel : '');
+ }
+ function scrollWhen(c) {
+ if (whenRaf || typeof document === 'undefined') return;
+ whenRaf = requestAnimationFrame(() => {
+ whenRaf = 0;
+ const list = c?.winList ? c.winList() : null;
+ const rows = list ? document.querySelectorAll('.notes-feed > .row[data-key]') : [];
+ const head = document.querySelector('.brand-header');
+ const top = head ? Math.max(0, head.getBoundingClientRect().bottom) : 0;
+ // the post at the top of the screen, below the bar
+ let key = null, box = null;
+ for (const r of rows) {
+ const b = r.getBoundingClientRect();
+ if (b.bottom > top + 12) { key = r.getAttribute('data-key'); box = r.parentElement.getBoundingClientRect(); break; }
+ }
+ if (whenIdx.list !== list) whenIdx = { list, map: list ? new Map(list.map((e) => [e.id, e])) : null };
+ const ev = key && whenIdx.map?.get(key);
+ // only once you're past the first screenful: at the top the posts' own times say it
+ if (!ev || (window.scrollY || 0) < window.innerHeight * 0.75) { if (whenEl) whenEl.classList.remove('on'); return; }
+ if (!whenEl) {
+ whenEl = document.createElement('div');
+ whenEl.className = 'feed-when';
+ whenEl.setAttribute('aria-hidden', 'true');
+ document.body.appendChild(whenEl);
+ }
+ const label = whenLabel(ev.created_at);
+ if (whenEl.textContent !== label) whenEl.textContent = label;
+ whenEl.style.top = (top + 8) + 'px';
+ whenEl.style.left = (box.left + box.width / 2) + 'px';
+ whenEl.classList.add('on');
+ clearTimeout(whenHide);
+ whenHide = setTimeout(() => whenEl && whenEl.classList.remove('on'), 1200);
+ });
+ }
async function loadOlderNotes(pk) {
const c = notesCache.get(pk);
if (!c || c.status !== 'ready' || c.loadingMore || c.end) return;
diff --git a/src/style.css b/src/style.css
index 9f2cd35..633d7f6 100644
--- a/src/style.css
+++ b/src/style.css
@@ -2197,3 +2197,17 @@ html:has(.call-overlay:not(.call-min)) { overflow: hidden; scrollbar-gutter: aut
.balance-settings-row .bs-title { font-weight: 600; }
.balance-settings-row .bs-tail { color: var(--muted); font-size: 20px; line-height: 1; flex-shrink: 0; width: 14px; text-align: center; }
.settings-prefs select { flex: 1 1 0; min-width: 0; }
+
+/* How far back the feed is scrolled: the post at the top of the screen's
+ date, under the top bar while scrolling (scrollWhen in messages.js). */
+.feed-when {
+ position: fixed; z-index: 29; transform: translate(-50%, -4px);
+ padding: 5px 12px; border-radius: 999px; white-space: nowrap;
+ font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
+ background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--ink);
+ border: 1px solid var(--line-strong);
+ -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
+ box-shadow: 0 2px 10px rgba(0, 0, 0, .14);
+ pointer-events: none; opacity: 0; transition: opacity .25s, transform .25s;
+}
+.feed-when.on { opacity: 1; transform: translate(-50%, 0); }