summaryrefslogtreecommitdiff
path: root/web-ui/app/js/mail_list/domain/refresher.js
blob: f1fe504d92c933af8d8fe5366f2fdb0ddb6c71d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
define(['flight/lib/component', 'page/events'], function(defineComponent, events) {
    'use strict';

    return defineComponent(refresher);

    function refresher() {
      this.defaultAttrs({
        interval: 20000
      });

      this.setupRefresher = function() {
        setTimeout(this.doRefresh.bind(this), this.attr.interval);
      };

      this.doRefresh = function() {
        this.trigger(document, events.ui.mails.refresh);
        this.setupRefresher();
      };

      this.after('initialize', function () {
        this.setupRefresher();
      });
    }
  }
);