[polari/wip/fmuellner/window-experiments: 6/30] chatView: Store pending logs as messages
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/window-experiments: 6/30] chatView: Store pending logs as messages
- Date: Mon, 18 Jul 2016 12:45:20 +0000 (UTC)
commit f1b7d50a4c53f5bef55d253cc7fa7164fa1cc207
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Jul 16 02:58:28 2016 +0200
chatView: Store pending logs as messages
We are not using anything from log events besides the properties
we have in the data object we pass to insertMessage(), so we can
just create those immediately and store them instead of the log
events themselves. As we are about to insert pending Tp.Messages
together with logs, this means we can operate on a single data
type.
https://bugzilla.gnome.org/show_bug.cgi?id=768907
src/chatView.js | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 2268e18..ade250b 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -473,7 +473,8 @@ const ChatView = new Lang.Class({
this._fetchingBacklog = false;
let [, events] = lw.get_events_finish(res);
- this._pendingLogs = events.concat(this._pendingLogs);
+ let messages = events.map(e => this._createMessage(e));
+ this._pendingLogs = messages.concat(this._pendingLogs);
this._insertPendingLogs();
},
@@ -502,12 +503,12 @@ const ChatView = new Lang.Class({
return;
let index = -1;
- let nick = this._pendingLogs[0].sender.alias;
- let type = this._pendingLogs[0].message_type;
+ let nick = this._pendingLogs[0].nick;
+ let type = this._pendingLogs[0].messageType;
if (!this._logWalker.is_end()) {
for (let i = 0; i < this._pendingLogs.length; i++)
- if (this._pendingLogs[i].sender.alias != nick ||
- this._pendingLogs[i].message_type != type) {
+ if (this._pendingLogs[i].nick != nick ||
+ this._pendingLogs[i].messageType != type) {
index = i;
break;
}
@@ -524,8 +525,7 @@ const ChatView = new Lang.Class({
let state = { lastNick: null, lastTimestamp: 0 };
let iter = this._view.buffer.get_start_iter();
for (let i = 0; i < pending.length; i++) {
- let message = this._createMessage(pending[i]);
- this._insertMessage(iter, message, state);
+ this._insertMessage(iter, pending[i], state);
if (!iter.is_end() || i < pending.length - 1)
this._view.buffer.insert(iter, '\n', -1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]