diff --git a/packages/cory/chat/chat.js b/packages/cory/chat/chat.js index bda0bb3c..59e2eb77 100644 --- a/packages/cory/chat/chat.js +++ b/packages/cory/chat/chat.js @@ -219,8 +219,8 @@ function updateWindows() { for (let j in conversations) { terminal.print({ command: "/command " + JSON.stringify({action: "window", account: account.id, conversation: j}), - value: j ? j : "", - style: (conversations[j] == gCurrentConversation ? "font-weight: bold; " : "") + "color: white", + value: (j ? j : "") + (conversations[j].unread ? " (" + conversations[j].unread + ")" : ""), + style: (conversations[j] == gCurrentConversation ? "background-color: white; color: black" : ""), }); } } @@ -252,15 +252,16 @@ function updateConversation() { terminal.clear(); printToConversation(gCurrentConversation, ["[", gCurrentConversation.name, "]"]); if (history) { - let previous = Promise.resolve(); for (let message of history) { - previous = previous.then(x => printToConversation(gCurrentConversation, message)); + printToConversation(gCurrentConversation, message); } } updateUsers(); } finally { terminal.uncork(); } + gCurrentConversation.unread = 0; + updateWindows(); }).catch(function(error) { terminal.print(error); }); @@ -313,6 +314,7 @@ function getConversation(session, conversationName) { return session.sendMessage(key, message); }, participants: [], + unread: 0, }; updateWindows(); } @@ -342,6 +344,9 @@ function printToConversation(conversation, message, notify) { } else { terminal.print(message); } + } else { + conversation.unread++; + updateWindows(); } if (notify && !gFocus) { gUnread++; diff --git a/packages/cory/libirc/libirc.js b/packages/cory/libirc/libirc.js index 8a765a03..2b8ca2a0 100644 --- a/packages/cory/libirc/libirc.js +++ b/packages/cory/libirc/libirc.js @@ -32,6 +32,7 @@ class IrcService { self._service = new ChatService(options.callback); self._name = options.name; self._nick = options.nick; + self._autoJoinChannels = options.autoJoinChannels; self._nameReplies = {}; network.newConnection().then(function(socket) { @@ -103,6 +104,10 @@ class IrcService { for (let i in conversations) { 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 if (!this._nameReplies[parts[3]]) { this._nameReplies[parts[3]] = []; diff --git a/packages/cory/news/news.js b/packages/cory/news/news.js index 90c42446..3a196344 100644 --- a/packages/cory/news/news.js +++ b/packages/cory/news/news.js @@ -8,6 +8,9 @@ list feed:username,url {id, title, modified, read, ...} */ +// [ ] New news article is posted. +// [ ] Existing news article is updated. + let http = require("libhttp"); let liblist = require("liblist"); let xml = require("libxml"); @@ -198,16 +201,18 @@ class TestInterface { terminal.select("headlines"); terminal.clear(); this.news.forEach((article, index) => { - let color = ""; - if (this.selectedIndex == index) { - color = "red"; - } else if (article.read) { - color = "gray"; + if (Math.abs(index - this.selectedIndex) < 5) { + let color = ""; + if (this.selectedIndex == index) { + color = "red"; + } 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.clear(); @@ -242,7 +247,7 @@ class TestInterface { async activate() { let self = this; 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}, ]); self.refreshNews().then(self.redisplay.bind(self)).catch(terminal.print);