Commit bc1e0279 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_jabber_client] Defer the page refresh

Wait a bit before triggering a refresh to prevent multiple refresh when many notifications occur
parent b34042dd
...@@ -259,7 +259,7 @@ ...@@ -259,7 +259,7 @@
return gadget.state_parameter_dict.volatile_jio.put(from, doc); return gadget.state_parameter_dict.volatile_jio.put(from, doc);
}) })
.push(function () { .push(function () {
return gadget.refresh(); return gadget.deferRefresh();
}); });
}) })
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
return gadget.state_parameter_dict.volatile_jio.put(argument_list[0], doc); return gadget.state_parameter_dict.volatile_jio.put(argument_list[0], doc);
}) })
.push(function () { .push(function () {
return gadget.refresh(); return gadget.deferRefresh();
}); });
}) })
...@@ -383,6 +383,18 @@ ...@@ -383,6 +383,18 @@
.declareAcquiredMethod('redirect', 'redirect') .declareAcquiredMethod('redirect', 'redirect')
.declareAcquiredMethod('getUrlFor', 'getUrlFor') .declareAcquiredMethod('getUrlFor', 'getUrlFor')
.declareAcquiredMethod('refresh', 'refresh') .declareAcquiredMethod('refresh', 'refresh')
.declareJob('deferRefresh', function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
// Wait a bit before triggering a refresh
// to prevent multiple refresh when many notifications occur
return RSVP.delay(200);
})
.push(function () {
return gadget.refresh();
});
})
.declareMethod('createJio', function () { .declareMethod('createJio', function () {
return this.state_parameter_dict.persistent_jio.createJio({ return this.state_parameter_dict.persistent_jio.createJio({
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.13623.60350.63692</string> </value> <value> <string>963.13624.8061.44390</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1509724327.32</float> <float>1510064649.5</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment