diff --git a/src/renderer/scr.savefile.js b/src/renderer/scr.savefile.js index e532cd8..f87f7e7 100644 --- a/src/renderer/scr.savefile.js +++ b/src/renderer/scr.savefile.js @@ -20,13 +20,21 @@ SAVEFILE.prototype.getServer = function(index){ }; SAVEFILE.prototype.getChannels = function(){ - return this.meta.channels || {}; + return this.meta.channels; +}; + +SAVEFILE.prototype.getChannelById = function(channel){ + return this.meta.channels[channel] || { id: channel, name: channel }; }; SAVEFILE.prototype.getUser = function(index){ return this.meta.users[this.meta.userindex[index]] || { name: "<unknown>" }; }; +SAVEFILE.prototype.getUserById = function(user){ + return this.meta.users[user] || { name: user }; +}; + SAVEFILE.prototype.getMessageCount = function(channel){ return Object.keys(this.data[channel]).length || 0; }; diff --git a/src/renderer/src.state.js b/src/renderer/src.state.js index 05c6cec..b8c63e9 100644 --- a/src/renderer/src.state.js +++ b/src/renderer/src.state.js @@ -21,6 +21,14 @@ var STATE = (function(){ })); }, + getChannelName: function(channel){ + return FILE.getChannelById(channel).name; + }, + + getUserName: function(user){ + return FILE.getUserById(user).name; + }, + selectChannel: function(channel){ selectedChannel = channel; MSGS = Object.keys(FILE.getMessages(channel)).sort();