1
0
mirror of https://github.com/chylex/Discord-History-Tracker.git synced 2025-04-10 17:15:43 +02:00

Add a way of retrieving channel and user names from renderer state object

This commit is contained in:
chylex 2016-10-27 16:49:51 +02:00
parent b97c483be9
commit a42a7b6913
2 changed files with 17 additions and 1 deletions

View File

@ -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;
};

View File

@ -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();