diff --git a/web/js/damus.js b/web/js/damus.js index 0543808..f48e35d 100644 --- a/web/js/damus.js +++ b/web/js/damus.js @@ -57,14 +57,16 @@ async function damus_web_init_ready() { if (err) { window.alert("Unable to load contacts."); } - await model_load_events(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_show_spinner(true); document.addEventListener('visibilitychange', () => { - update_title(model) + update_title(model); }); on_timer_timestamps(); on_timer_invalidations(); @@ -127,6 +129,7 @@ async function on_pool_eose(relay, sub_id) { if (!model.inited) { model.inited = true; } + view_show_spinner(false); break; case ids.profiles: model.pool.unsubscribe(ids.profiles, relay); diff --git a/web/js/ui/state.js b/web/js/ui/state.js index 2bd1151..3ebd286 100644 --- a/web/js/ui/state.js +++ b/web/js/ui/state.js @@ -60,7 +60,6 @@ function view_timeline_apply_mode(model, mode, opts={}) { count++; } if (count > 0) { - find_node("#view .loading-events").classList.add("hide"); el.append(fragment); view_set_show_count(0); view_timeline_update_timestamps(); @@ -69,6 +68,10 @@ function view_timeline_apply_mode(model, mode, opts={}) { 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 * or removes them from the timeline. */ @@ -114,7 +117,7 @@ function view_timeline_update(model) { // If we have things to show and we have initted and we don't have // anything update the current view if (!latest_ev && model.inited) { - view_timeline_show_new(model); + view_timeline_show_new(model); } view_set_show_count(count, true, !model.inited); } @@ -156,7 +159,6 @@ function view_timeline_show_new(model) { count++; } if (count > 0) { - find_node("#view .loading-events").classList.add("hide"); el.prepend(fragment); } view_set_show_count(-count, true);