Files
marco/app/controllers/activity.js
T
raucao 9a5517012c Fix activity feed first load, sender names, and infinite scroll
- Treat contacts as loaded only once the kind 3 event exists, so the first
  home window is fetched with the follow list, and re-fetch the initial window
  when contacts arrive late.
- Resolve sender kind 0 profiles from the user's relays and the content's
  origin relays, and retry unresolved senders after the first load.
- Auto-load older pages while the end sentinel stays visible via a service-side
  loop, guarded by hasMore and a fetch lock, with an epoch token so a mode
  switch invalidates in-flight fetches.
- Deduplicate zap entries across window re-fetches.
2026-11-17 00:31:06 +04:00

85 lines
1.7 KiB
JavaScript

import Controller from '@ember/controller';
import { service } from '@ember/service';
import { action } from '@ember/object';
import { task } from 'ember-concurrency';
export default class ActivityController extends Controller {
@service router;
@service mapUi;
@service nostrAuth;
@service activity;
loadTask = task({ restartable: true }, async (pubkey) => {
await this.activity.load(pubkey);
});
get scrollTop() {
return this.mapUi.getScrollPosition('activity');
}
get items() {
return this.activity.items;
}
get isLoading() {
return this.activity.isLoading;
}
get isConnected() {
return this.nostrAuth.isConnected;
}
get sourceMode() {
return this.activity.sourceMode;
}
get isLoadingMore() {
return this.activity.isLoadingMore;
}
get hasMore() {
return this.activity.hasMore;
}
@action
setSourceMode(mode) {
this.activity.setSourceMode(mode);
}
@action
onSentinelVisibility(visible) {
this.activity.setSentinelVisible(visible);
}
@action
selectItem(item) {
if (!item || !item.placeIdentifier) return;
const sidebarContent = document.querySelector('.sidebar-content');
if (sidebarContent) {
this.mapUi.saveScrollPosition('activity', sidebarContent.scrollTop);
}
this.mapUi.returnToRoute = { name: 'activity' };
this.mapUi.showSidebar();
this.mapUi.preventNextZoom = true;
this.router.transitionTo(`/place/${item.placeIdentifier}`);
}
@action
onNostrConnected() {
this.loadTask.perform(this.nostrAuth.pubkey);
}
@action
backToMenu() {
this.router.transitionTo('menu');
}
@action
close() {
this.router.transitionTo('index');
}
}