web: more caching fixes

This commit is contained in:
Thomas Mathews 2022-12-20 19:17:07 -08:00
parent add261dd01
commit d9d293901b
2 changed files with 10 additions and 5 deletions

View file

@ -57,14 +57,16 @@ async function damus_web_init_ready() {
if (err) { if (err) {
window.alert("Unable to load contacts."); window.alert("Unable to load contacts.");
} }
await model_load_events(model, (ev)=> { await model_load_events(model, (ev)=> {
model_process_event(model, ev); model_process_event(model, ev);
}); });
log_debug("loaded events", Object.keys(model.all_events).length);
view_timeline_update(model);
view_timeline_apply_mode(model, VM_FRIENDS); view_timeline_apply_mode(model, VM_FRIENDS);
view_show_spinner(true);
document.addEventListener('visibilitychange', () => { document.addEventListener('visibilitychange', () => {
update_title(model) update_title(model);
}); });
on_timer_timestamps(); on_timer_timestamps();
on_timer_invalidations(); on_timer_invalidations();
@ -127,6 +129,7 @@ async function on_pool_eose(relay, sub_id) {
if (!model.inited) { if (!model.inited) {
model.inited = true; model.inited = true;
} }
view_show_spinner(false);
break; break;
case ids.profiles: case ids.profiles:
model.pool.unsubscribe(ids.profiles, relay); model.pool.unsubscribe(ids.profiles, relay);

View file

@ -60,7 +60,6 @@ function view_timeline_apply_mode(model, mode, opts={}) {
count++; count++;
} }
if (count > 0) { if (count > 0) {
find_node("#view .loading-events").classList.add("hide");
el.append(fragment); el.append(fragment);
view_set_show_count(0); view_set_show_count(0);
view_timeline_update_timestamps(); view_timeline_update_timestamps();
@ -69,6 +68,10 @@ function view_timeline_apply_mode(model, mode, opts={}) {
return mode; return mode;
} }
function view_show_spinner(show=true) {
find_node("#view .loading-events").classList.toggle("hide", !show);
}
/* view_timeline_update iterates through invalidated event ids and either adds /* view_timeline_update iterates through invalidated event ids and either adds
* or removes them from the timeline. * or removes them from the timeline.
*/ */
@ -156,7 +159,6 @@ function view_timeline_show_new(model) {
count++; count++;
} }
if (count > 0) { if (count > 0) {
find_node("#view .loading-events").classList.add("hide");
el.prepend(fragment); el.prepend(fragment);
} }
view_set_show_count(-count, true); view_set_show_count(-count, true);