Created
March 22, 2017 10:56
-
-
Save azhurb/391ac900ae90a607fba1c9d66bf2f4f5 to your computer and use it in GitHub Desktop.
Fix message lifetime (issue #11418)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: c/alert.js | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- c/alert.js (revision ff79bf4c36ac0a7b2968e24beb7c4dd22b8e4793) | |
+++ c/alert.js (revision cf16b1d28aaa90ac0dc713fa523c0311f8495aa5) | |
@@ -131,6 +131,13 @@ | |
this.show(msg); | |
}else if (typeof(msg) == 'object'){ | |
+ if (msg.hasOwnProperty('valid_until') && msg.valid_until && msg.valid_until < (new Date().getTime())/1000){ | |
+ _debug('remove expired message from the queue'); | |
+ this.queue.splice(0, 1); | |
+ this.queue_handler(); | |
+ return; | |
+ } | |
+ | |
if (msg.hasOwnProperty('confirm_callback')){ | |
this.set_confirm_callback(msg.confirm_callback); | |
} | |
Index: c/watchdog.js | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- c/watchdog.js (revision ff79bf4c36ac0a7b2968e24beb7c4dd22b8e4793) | |
+++ c/watchdog.js (revision cf16b1d28aaa90ac0dc713fa523c0311f8495aa5) | |
@@ -161,62 +161,62 @@ | |
if (data.event == 'send_msg_with_video'){ | |
- stb.msg.set_callback( | |
- function(){ | |
- self.send_confirm(); | |
+ var msg_callback = function(){ | |
+ self.send_confirm(); | |
- var video = { | |
- name : "", | |
- cmd : data.param1, | |
- promo : true | |
- }; | |
+ var video = { | |
+ name : "", | |
+ cmd : data.param1, | |
+ promo : true | |
+ }; | |
- if (stb.player.on){ | |
- video.restore_item = stb.player.cur_media_item.clone(); | |
+ if (stb.player.on){ | |
+ video.restore_item = stb.player.cur_media_item.clone(); | |
- _debug('stb.cur_layer.layer_name', stb.cur_layer.layer_name); | |
+ _debug('stb.cur_layer.layer_name', stb.cur_layer.layer_name); | |
- if (stb.cur_layer.layer_name === "vclub"){ | |
- video.restore_item.position = stb.GetPosTime && stb.GetPosTime(); | |
- } | |
- } | |
+ if (stb.cur_layer.layer_name === "vclub"){ | |
+ video.restore_item.position = stb.GetPosTime && stb.GetPosTime(); | |
+ } | |
+ } | |
- if (stb.cur_layer.on){ | |
- stb.cur_layer.hide(); | |
- video.restore_layer = stb.cur_layer; | |
- } | |
+ if (stb.cur_layer.on){ | |
+ stb.cur_layer.hide(); | |
+ video.restore_layer = stb.cur_layer; | |
+ } | |
- video.stop_callback = function(){ | |
- _debug('promo_video.stop_callback'); | |
+ video.stop_callback = function(){ | |
+ _debug('promo_video.stop_callback'); | |
- if (stb.player.cur_media_item.restore_layer){ | |
- stb.player.cur_media_item.restore_layer.show(); | |
- } | |
+ if (stb.player.cur_media_item.restore_layer){ | |
+ stb.player.cur_media_item.restore_layer.show(); | |
+ } | |
- if (stb.player.cur_media_item.restore_item){ | |
- stb.player.play(stb.player.cur_media_item.restore_item); | |
- } | |
- }; | |
+ if (stb.player.cur_media_item.restore_item){ | |
+ stb.player.play(stb.player.cur_media_item.restore_item); | |
+ } | |
+ }; | |
- stb.player.play(video); | |
- }); | |
+ stb.player.play(video); | |
+ }; | |
}else{ | |
- stb.msg.set_callback( | |
- function(){ | |
- self.send_confirm(function(){ | |
- if (data.reboot_after_ok == 1){ | |
- stb.Stop(); | |
- stb.ExecAction('reboot'); | |
- } | |
- }); | |
+ msg_callback = function(){ | |
+ self.send_confirm(function(){ | |
+ if (data.reboot_after_ok == 1){ | |
+ stb.Stop(); | |
+ stb.ExecAction('reboot'); | |
+ } | |
}); | |
+ }; | |
} | |
stb.msg.push( | |
{ | |
msg : (data.send_time ? '<span style="color: #555">[' + data.send_time + ']</span> ' : '') + data.msg.replace('%mac%', stb.mac).replace('%sn%', stb.serial_number), | |
- auto_hide_timeout : data.auto_hide_timeout || 0 | |
+ auto_hide_timeout : data.auto_hide_timeout || 0, | |
+ callback : msg_callback || function () {}, | |
+ valid_until : data.valid_until | |
} | |
); | |
Index: server/lib/watchdog.class.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- server/lib/watchdog.class.php (revision ff79bf4c36ac0a7b2968e24beb7c4dd22b8e4793) | |
+++ server/lib/watchdog.class.php (revision cf16b1d28aaa90ac0dc713fa523c0311f8495aa5) | |
@@ -72,6 +72,7 @@ | |
$res['data']['reboot_after_ok'] = $events[0]['reboot_after_ok']; | |
$res['data']['auto_hide_timeout'] = $events[0]['auto_hide_timeout']; | |
$res['data']['param1'] = $events[0]['param1']; | |
+ $res['data']['valid_until'] = strtotime($events[0]['eventtime']); | |
if (Config::getSafe('display_send_time_in_message', false)){ | |
$res['data']['send_time'] = $events[0]['addtime']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment