telepathyClient: Use GObjects based message objects
As per commit b5676a2a5
ChatNotification is a GObject, but I was wrongly
considering that it was using Tp.Message's as children, instead it just
uses custom-built objects to pass information around through signals.
Given gjs can only use GObjects as signal parameters, create a small wrapper
class to hold the ChatNotification messages and use it as signal parameter.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2449
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1112
This commit is contained in:
parent
53e8285cf0
commit
766288eec1
@ -2,7 +2,6 @@
|
|||||||
/* exported Component */
|
/* exported Component */
|
||||||
|
|
||||||
const { Clutter, Gio, GLib, GObject, St } = imports.gi;
|
const { Clutter, Gio, GLib, GObject, St } = imports.gi;
|
||||||
const Lang = imports.lang;
|
|
||||||
|
|
||||||
var Tpl = null;
|
var Tpl = null;
|
||||||
var Tp = null;
|
var Tp = null;
|
||||||
@ -630,11 +629,19 @@ class ChatSource extends MessageTray.Source {
|
|||||||
}
|
}
|
||||||
}) : null;
|
}) : null;
|
||||||
|
|
||||||
|
const ChatNotificationMessage = HAVE_TP ? GObject.registerClass(
|
||||||
|
class ChatNotificationMessage extends GObject.Object {
|
||||||
|
_init(props = {}) {
|
||||||
|
super._init();
|
||||||
|
this.set(props);
|
||||||
|
}
|
||||||
|
}) : null;
|
||||||
|
|
||||||
var ChatNotification = HAVE_TP ? GObject.registerClass({
|
var ChatNotification = HAVE_TP ? GObject.registerClass({
|
||||||
Signals: {
|
Signals: {
|
||||||
'message-removed': { param_types: [Tp.Message.$gtype] },
|
'message-removed': { param_types: [ChatNotificationMessage.$gtype] },
|
||||||
'message-added': { param_types: [Tp.Message.$gtype] },
|
'message-added': { param_types: [ChatNotificationMessage.$gtype] },
|
||||||
'timestamp-changed': { param_types: [Tp.Message.$gtype] },
|
'timestamp-changed': { param_types: [ChatNotificationMessage.$gtype] },
|
||||||
},
|
},
|
||||||
}, class ChatNotification extends MessageTray.Notification {
|
}, class ChatNotification extends MessageTray.Notification {
|
||||||
_init(source) {
|
_init(source) {
|
||||||
@ -735,21 +742,24 @@ var ChatNotification = HAVE_TP ? GObject.registerClass({
|
|||||||
styles: [],
|
styles: [],
|
||||||
timestamp: currentTime,
|
timestamp: currentTime,
|
||||||
noTimestamp: false });
|
noTimestamp: false });
|
||||||
|
const { noTimestamp } = props;
|
||||||
|
delete props.noTimestamp;
|
||||||
|
|
||||||
// Reset the old message timeout
|
// Reset the old message timeout
|
||||||
if (this._timestampTimeoutId)
|
if (this._timestampTimeoutId)
|
||||||
GLib.source_remove(this._timestampTimeoutId);
|
GLib.source_remove(this._timestampTimeoutId);
|
||||||
this._timestampTimeoutId = 0;
|
this._timestampTimeoutId = 0;
|
||||||
|
|
||||||
let message = { realMessage: props.group != 'meta',
|
let message = new ChatNotificationMessage({
|
||||||
showTimestamp: false };
|
realMessage: props.group !== 'meta',
|
||||||
Lang.copyProperties(props, message);
|
showTimestamp: false,
|
||||||
delete message.noTimestamp;
|
...props,
|
||||||
|
});
|
||||||
|
|
||||||
this.messages.unshift(message);
|
this.messages.unshift(message);
|
||||||
this.emit('message-added', message);
|
this.emit('message-added', message);
|
||||||
|
|
||||||
if (!props.noTimestamp) {
|
if (!noTimestamp) {
|
||||||
let timestamp = props.timestamp;
|
let timestamp = props.timestamp;
|
||||||
if (timestamp < currentTime - SCROLLBACK_IMMEDIATE_TIME) {
|
if (timestamp < currentTime - SCROLLBACK_IMMEDIATE_TIME) {
|
||||||
this.appendTimestamp();
|
this.appendTimestamp();
|
||||||
|
Loading…
Reference in New Issue
Block a user