Saving last channel collapsed state

This commit is contained in:
WolverinDEV 2020-04-18 21:31:13 +02:00
parent b46a7f59f5
commit ee994641ef
2 changed files with 12 additions and 2 deletions

View file

@ -366,6 +366,13 @@ export class Settings extends StaticSettings {
}
};
static readonly FN_SERVER_CHANNEL_COLLAPSED: (channel_id: number) => SettingsKey<boolean> = channel => {
return {
key: 'channel_collapsed_' + channel,
default_value: false
}
};
static readonly FN_PROFILE_RECORD: (name: string) => SettingsKey<any> = name => {
return {
key: 'profile_record' + name

View file

@ -176,7 +176,7 @@ export class ChannelEntry extends ChannelTreeEntry<ChannelEvents> {
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<ChannelEvents> {
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<ChannelEvents> {
}
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<ChannelEvents> {
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 {