Some improvements to constructPresence
Don't <show> 'offline'. Only include status_message when explicitly passed in as a string.
This commit is contained in:
parent
f70a3c3ed2
commit
7398d41405
@ -1431,15 +1431,11 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
constructPresence: function (type, status_message) {
|
constructPresence: function (type, status_message) {
|
||||||
if (typeof type !== 'string') {
|
|
||||||
type = this.get('status') || converse.default_state;
|
|
||||||
}
|
|
||||||
if (typeof status_message !== 'string') {
|
|
||||||
status_message = this.get('status_message');
|
|
||||||
}
|
|
||||||
var presence;
|
var presence;
|
||||||
|
type = typeof type === 'string' ? type : (this.get('status') || converse.default_state);
|
||||||
|
status_message = typeof status_message === 'string' ? status_message : undefined;
|
||||||
// Most of these presence types are actually not explicitly sent,
|
// Most of these presence types are actually not explicitly sent,
|
||||||
// but I add all of them here fore reference and future proofing.
|
// but I add all of them here for reference and future proofing.
|
||||||
if ((type === 'unavailable') ||
|
if ((type === 'unavailable') ||
|
||||||
(type === 'probe') ||
|
(type === 'probe') ||
|
||||||
(type === 'error') ||
|
(type === 'error') ||
|
||||||
@ -1450,18 +1446,13 @@
|
|||||||
presence = $pres({'type': type});
|
presence = $pres({'type': type});
|
||||||
} else if (type === 'offline') {
|
} else if (type === 'offline') {
|
||||||
presence = $pres({'type': 'unavailable'});
|
presence = $pres({'type': 'unavailable'});
|
||||||
if (status_message) {
|
} else if (type === 'online') {
|
||||||
presence.c('show').t(type);
|
presence = $pres();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (type === 'online') {
|
presence = $pres().c('show').t(type).up();
|
||||||
presence = $pres();
|
}
|
||||||
} else {
|
if (status_message) {
|
||||||
presence = $pres().c('show').t(type).up();
|
presence.c('status').t(status_message);
|
||||||
}
|
|
||||||
if (status_message) {
|
|
||||||
presence.c('status').t(status_message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return presence;
|
return presence;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user