Tell the UI why the device became unusable.

This commit is contained in:
Simo Kinnunen
2014-07-23 17:58:08 +09:00
parent d8dec38cad
commit 0ec8082ac1
3 changed files with 10 additions and 4 deletions

View File

@@ -72,7 +72,7 @@ module.exports = syrup.serial()
}
}
plugin.leave = function() {
plugin.leave = function(reason) {
return plugin.get()
.then(function(group) {
log.important('No longer owned by "%s"', group.email)
@@ -86,6 +86,7 @@ module.exports = syrup.serial()
, wireutil.envelope(new wire.LeaveGroupMessage(
options.serial
, group
, reason
))
])
@@ -136,7 +137,7 @@ module.exports = syrup.serial()
var reply = wireutil.reply(options.serial)
grouputil.match(ident, message.requirements)
.then(function() {
return plugin.leave()
return plugin.leave('ungroup_request')
})
.then(function() {
push.send([
@@ -154,12 +155,12 @@ module.exports = syrup.serial()
channels.on('timeout', function(channel) {
if (currentGroup && channel === currentGroup.group) {
plugin.leave()
plugin.leave('automatic_timeout')
}
})
lifecycle.observe(function() {
return plugin.leave()
return plugin.leave('lifecycle_ended')
.catch(grouputil.NoGroupError, function() {
return true
})