From ee994641efa450294ddcfbd3b979a8a79c9a0955 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 18 Apr 2020 21:31:13 +0200 Subject: [PATCH] Saving last channel collapsed state --- shared/js/settings.ts | 7 +++++++ shared/js/ui/channel.ts | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/shared/js/settings.ts b/shared/js/settings.ts index 894d9914..03a5474f 100644 --- a/shared/js/settings.ts +++ b/shared/js/settings.ts @@ -366,6 +366,13 @@ export class Settings extends StaticSettings { } }; + static readonly FN_SERVER_CHANNEL_COLLAPSED: (channel_id: number) => SettingsKey = channel => { + return { + key: 'channel_collapsed_' + channel, + default_value: false + } + }; + static readonly FN_PROFILE_RECORD: (name: string) => SettingsKey = name => { return { key: 'profile_record' + name diff --git a/shared/js/ui/channel.ts b/shared/js/ui/channel.ts index 401c7aaf..1bfc493b 100644 --- a/shared/js/ui/channel.ts +++ b/shared/js/ui/channel.ts @@ -176,7 +176,7 @@ export class ChannelEntry extends ChannelTreeEntry { private _cached_channel_description_promise_resolve: any = undefined; private _cached_channel_description_promise_reject: any = undefined; - private _flag_collapsed: boolean; //TODO: Load from config! + private _flag_collapsed: boolean; private _flag_subscribed: boolean; private _subscribe_mode: ChannelSubscribeMode; @@ -199,7 +199,7 @@ export class ChannelEntry extends ChannelTreeEntry { this.client_property_listener = (event: ClientEvents["notify_properties_updated"]) => { if(typeof event.updated_properties.client_nickname !== "undefined" || typeof event.updated_properties.client_talk_power !== "undefined") this.reorderClientList(true); - } + }; } destroy() { @@ -691,6 +691,8 @@ export class ChannelEntry extends ChannelTreeEntry { } get collapsed() : boolean { + if(typeof this._flag_collapsed === "undefined") + this._flag_collapsed = this.channelTree.client.settings.server(Settings.FN_SERVER_CHANNEL_COLLAPSED(this.channelId)); return this._flag_collapsed; } @@ -700,6 +702,7 @@ export class ChannelEntry extends ChannelTreeEntry { this._flag_collapsed = flag; this.events.fire("notify_collapsed_state_changed", { collapsed: flag }); this.view.current?.forceUpdate(); + this.channelTree.client.settings.changeServer(Settings.FN_SERVER_CHANNEL_COLLAPSED(this.channelId), flag); } get flag_subscribed() : boolean {