Sha256: 1bfbf1dd2313857696428e6da2b5be6eef6551c628907c71e29d0ee67dc92171

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

import Route from "@ember/routing/route";
import {
  default as MessageCollection,
  SEVERITIES
} 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);
    SEVERITIES.forEach(severity =>
      model.set(`show${severity}`, controller[`show${severity}`])
    );
    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

12 entries across 12 versions & 1 rubygems

Version Path
logster-2.11.4 client-app/app/routes/index.js
logster-2.11.3 client-app/app/routes/index.js
logster-2.11.2 client-app/app/routes/index.js
logster-2.11.1 client-app/app/routes/index.js
logster-2.11.0 client-app/app/routes/index.js
logster-2.10.1 client-app/app/routes/index.js
logster-2.10.0 client-app/app/routes/index.js
logster-2.9.8 client-app/app/routes/index.js
logster-2.9.7 client-app/app/routes/index.js
logster-2.9.6 client-app/app/routes/index.js
logster-2.9.5 client-app/app/routes/index.js
logster-2.9.4 client-app/app/routes/index.js