Sha256: 0b17e8ccaea560d3e2410524c76dae8509c2d7bb7a798deb66e23e4e652137d2
Contents?: true
Size: 1.08 KB
Versions: 13
Compression:
Stored size: 1.08 KB
Contents
import Route from "@ember/routing/route"; import MessageCollection from "client-app/models/message-collection"; import { isHidden } from "client-app/lib/utilities"; export default Route.extend({ model() { // TODO from preload json? return MessageCollection.create(); }, setupController(controller, model) { this._super(controller, model); model.reload(); let times = 0; let backoff = 1; this.refreshInterval = setInterval(() => { if (model.loading) { return; } times += 1; const hidden = isHidden(); let load = !hidden; if (hidden) { if (times % backoff === 0) { load = true; if (backoff < 20) { backoff++; } } } // refresh a lot less aggressively in background if (load) { model.loadMore(); if (!hidden) { backoff = 1; } } }, 3000); this.events.on("panelResized", amount => { controller.resizePanels(amount); }); }, deactivate() { clearInterval(this.refreshInterval); } });
Version data entries
13 entries across 13 versions & 1 rubygems