Various works in progress.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3376 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2017-01-11 02:14:22 +00:00
parent 15f3a3351e
commit 63361ec1f8
3 changed files with 29 additions and 14 deletions

View File

@ -219,8 +219,8 @@ function updateWindows() {
for (let j in conversations) { for (let j in conversations) {
terminal.print({ terminal.print({
command: "/command " + JSON.stringify({action: "window", account: account.id, conversation: j}), command: "/command " + JSON.stringify({action: "window", account: account.id, conversation: j}),
value: j ? j : "<service>", value: (j ? j : "<service>") + (conversations[j].unread ? " (" + conversations[j].unread + ")" : ""),
style: (conversations[j] == gCurrentConversation ? "font-weight: bold; " : "") + "color: white", style: (conversations[j] == gCurrentConversation ? "background-color: white; color: black" : ""),
}); });
} }
} }
@ -252,15 +252,16 @@ function updateConversation() {
terminal.clear(); terminal.clear();
printToConversation(gCurrentConversation, ["[", gCurrentConversation.name, "]"]); printToConversation(gCurrentConversation, ["[", gCurrentConversation.name, "]"]);
if (history) { if (history) {
let previous = Promise.resolve();
for (let message of history) { for (let message of history) {
previous = previous.then(x => printToConversation(gCurrentConversation, message)); printToConversation(gCurrentConversation, message);
} }
} }
updateUsers(); updateUsers();
} finally { } finally {
terminal.uncork(); terminal.uncork();
} }
gCurrentConversation.unread = 0;
updateWindows();
}).catch(function(error) { }).catch(function(error) {
terminal.print(error); terminal.print(error);
}); });
@ -313,6 +314,7 @@ function getConversation(session, conversationName) {
return session.sendMessage(key, message); return session.sendMessage(key, message);
}, },
participants: [], participants: [],
unread: 0,
}; };
updateWindows(); updateWindows();
} }
@ -342,6 +344,9 @@ function printToConversation(conversation, message, notify) {
} else { } else {
terminal.print(message); terminal.print(message);
} }
} else {
conversation.unread++;
updateWindows();
} }
if (notify && !gFocus) { if (notify && !gFocus) {
gUnread++; gUnread++;

View File

@ -32,6 +32,7 @@ class IrcService {
self._service = new ChatService(options.callback); self._service = new ChatService(options.callback);
self._name = options.name; self._name = options.name;
self._nick = options.nick; self._nick = options.nick;
self._autoJoinChannels = options.autoJoinChannels;
self._nameReplies = {}; self._nameReplies = {};
network.newConnection().then(function(socket) { network.newConnection().then(function(socket) {
@ -103,6 +104,10 @@ class IrcService {
for (let i in conversations) { for (let i in conversations) {
this._service.notifyPresenceChanged(conversations[i], person, "unavailable"); this._service.notifyPresenceChanged(conversations[i], person, "unavailable");
} }
} else if (parts[0] == "001") { // RPL_WELCOME
if (this._autoJoinChannels) {
this._send("JOIN " + this._autoJoinChannels);
}
} else if (parts[0] == "353") { // RPL_NAMREPLY } else if (parts[0] == "353") { // RPL_NAMREPLY
if (!this._nameReplies[parts[3]]) { if (!this._nameReplies[parts[3]]) {
this._nameReplies[parts[3]] = []; this._nameReplies[parts[3]] = [];

View File

@ -8,6 +8,9 @@
list feed:username,url {id, title, modified, read, ...} list feed:username,url {id, title, modified, read, ...}
*/ */
// [ ] New news article is posted.
// [ ] Existing news article is updated.
let http = require("libhttp"); let http = require("libhttp");
let liblist = require("liblist"); let liblist = require("liblist");
let xml = require("libxml"); let xml = require("libxml");
@ -198,16 +201,18 @@ class TestInterface {
terminal.select("headlines"); terminal.select("headlines");
terminal.clear(); terminal.clear();
this.news.forEach((article, index) => { this.news.forEach((article, index) => {
let color = ""; if (Math.abs(index - this.selectedIndex) < 5) {
if (this.selectedIndex == index) { let color = "";
color = "red"; if (this.selectedIndex == index) {
} else if (article.read) { color = "red";
color = "gray"; } else if (article.read) {
color = "gray";
}
terminal.print(article.modified.toString(), " ", {
style: color ? ("color: " + color) : "",
value: article.title,
});
} }
terminal.print(article.modified.toString(), " ", {
style: color ? ("color: " + color) : "",
value: article.title,
});
}); });
terminal.select("view"); terminal.select("view");
terminal.clear(); terminal.clear();
@ -242,7 +247,7 @@ class TestInterface {
async activate() { async activate() {
let self = this; let self = this;
terminal.split([ terminal.split([
{name: "headlines", basis: "30%", grow: 0, shrink: 1}, {name: "headlines", basis: "11rem", grow: 0, shrink: 1},
{name: "view", style: "display: flex", basis: "70%", grow: 2, shrink: 0}, {name: "view", style: "display: flex", basis: "70%", grow: 2, shrink: 0},
]); ]);
self.refreshNews().then(self.redisplay.bind(self)).catch(terminal.print); self.refreshNews().then(self.redisplay.bind(self)).catch(terminal.print);