fixed how channels and users are cached

This commit is contained in:
hydrabolt
2015-08-24 17:30:20 +01:00
parent ff0187a4b1
commit 97a6ff2772
6 changed files with 197 additions and 143 deletions

View File

@@ -5,6 +5,7 @@ class Channel {
this.name = data.name;
this.type = data.type;
this.id = data.id;
this.messages = [];
//this.isPrivate = isPrivate; //not sure about the implementation of this...
}
@@ -15,6 +16,22 @@ class Channel {
equals(object) {
return object.id === this.id;
}
addMessage(data){
if(!this.getMessage("id", data.id)){
this.messages.push(data);
}
return this.getMessage("id", data.id);
}
getMessage(key, value){
for(var message of this.messages){
if(message[key] === value){
return message;
}
}
return null;
}
}