Add a couple utility functions to renderer (retrieving messages and selected channel)

This commit is contained in:
chylex 2016-10-31 22:22:22 +01:00
parent 60a66690bd
commit 094ed75eca
2 changed files with 12 additions and 0 deletions

View File

@ -39,6 +39,10 @@ SAVEFILE.prototype.getMessageCount = function(channel){
return Object.keys(this.data[channel]).length || 0;
};
SAVEFILE.prototype.getAllMessages = function(){
return Array.prototype.concat.apply([], Object.values(this.data).map(messageList => Object.values(messageList)));
};
SAVEFILE.prototype.getMessages = function(channel){
return this.data[channel] || [];
};

View File

@ -42,6 +42,14 @@ var STATE = (function(){
});
},
getSelectedChannel: function(){
return selectedChannel;
},
getRawMessages: function(channel){
return channel ? Object.values(FILE.getMessages(channel)) : FILE.getAllMessages();
},
getMessageList: function(startIndex, count){
if (!MSGS){
return [];