Sha256: 64869a1608b0063ca4b667683fc207e35f97ddab2ca6c1121deb5b6ab628f47a

Contents?: true

Size: 1.36 KB

Versions: 15

Compression:

Stored size: 1.36 KB

Contents

import classic from "ember-classic-decorator";
import { inject as service } from "@ember/service";
import Route from "@ember/routing/route";
import MessageCollection, {
  SEVERITIES,
} from "client-app/models/message-collection";
import { isHidden } from "client-app/lib/utilities";

@classic
export default class IndexRoute extends Route {
  @service events;

  model() {
    // TODO from preload json?
    return MessageCollection.create();
  }

  setupController(controller, model) {
    super.setupController(controller, model);
    for (const severity of SEVERITIES) {
      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

15 entries across 15 versions & 1 rubygems

Version Path
logster-2.20.1 client-app/app/routes/index.js
logster-2.20.0 client-app/app/routes/index.js
logster-2.19.1 client-app/app/routes/index.js
logster-2.19.0 client-app/app/routes/index.js
logster-2.18.1 client-app/app/routes/index.js
logster-2.18.0 client-app/app/routes/index.js
logster-2.17.1 client-app/app/routes/index.js
logster-2.17.0 client-app/app/routes/index.js
logster-2.16.0 client-app/app/routes/index.js
logster-2.15.0 client-app/app/routes/index.js
logster-2.14.0 client-app/app/routes/index.js
logster-2.13.1 client-app/app/routes/index.js
logster-2.13.0 client-app/app/routes/index.js
logster-2.12.2 client-app/app/routes/index.js
logster-2.12.1 client-app/app/routes/index.js