summaryrefslogtreecommitdiff
path: root/ui/lib/store/channels.js
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-11-02 13:01:01 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-11-02 13:01:01 -0400
commite2908921d25347e3aab45afed9b9b4b807f79c25 (patch)
tree9e0e7361d9b397ad92c9109523c072e2c5c66bba /ui/lib/store/channels.js
parent8088a8bd8bced9127edcb2284b993332d291b443 (diff)
parenta32b0ab6ad7995b8fff98e423793a7c6521ea1e9 (diff)
Merge remote-tracking branch 'origin/wip/mobile'
Diffstat (limited to 'ui/lib/store/channels.js')
-rw-r--r--ui/lib/store/channels.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/ui/lib/store/channels.js b/ui/lib/store/channels.js
index b57ca7e..6d722c5 100644
--- a/ui/lib/store/channels.js
+++ b/ui/lib/store/channels.js
@@ -1,17 +1,26 @@
export class Channels {
constructor() {
this.channels = [];
+ this.channelData = {};
}
setChannels(channels) {
this.channels = [...channels];
this.sort();
+ this.channelData = channels.reduce(
+ (acc, val) => ({
+ ...acc,
+ [val.id]: val.name,
+ }),
+ {}
+ );
return this;
}
addChannel(id, name) {
this.channels = [...this.channels, { id, name }];
this.sort();
+ this.channelData[id] = name;
return this;
}
@@ -20,9 +29,14 @@ export class Channels {
if (channelIndex !== -1) {
this.channels.splice(channelIndex, 1);
}
+ delete this.channelData[id];
return this;
}
+ get(id) {
+ return this.channelData[id];
+ }
+
sort() {
this.channels.sort((a, b) => {
if (a.name < b.name) {