mirror of
https://github.com/vector-im/element-call.git
synced 2026-03-31 07:00:26 +00:00
Tidy settings
This commit is contained in:
@@ -70,10 +70,17 @@ export class Config {
|
||||
|
||||
private applyConfigToSettings(): void {
|
||||
if (!this.config) return;
|
||||
// only the value from config if it hasn't been overridden
|
||||
if (showNonMemberTiles.value === undefined) {
|
||||
showNonMemberTiles.setValue(this.config.show_non_member_tiles);
|
||||
}
|
||||
// use the value from config if it hasn't been overridden
|
||||
const showNonMemberTilesSubscription = showNonMemberTiles.value.subscribe(
|
||||
(val) => {
|
||||
if (val === undefined && this.config) {
|
||||
// we don't persist the value to local storage so that it is set from the config
|
||||
// file on every startup
|
||||
showNonMemberTiles.setValue(this.config.show_non_member_tiles, false);
|
||||
showNonMemberTilesSubscription.unsubscribe();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
public config?: ResolvedConfigOptions;
|
||||
|
||||
@@ -246,7 +246,7 @@ export const SettingsModal: FC<Props> = ({
|
||||
id="showNonMemberTiles"
|
||||
type="checkbox"
|
||||
label={t("settings.show_non_member_tiles")}
|
||||
checked={showNonMemberTiles}
|
||||
checked={!!showNonMemberTiles}
|
||||
onChange={useCallback(
|
||||
(event: ChangeEvent<HTMLInputElement>): void => {
|
||||
setShowNonMemberTiles(event.target.checked);
|
||||
|
||||
@@ -37,9 +37,11 @@ export class Setting<T> {
|
||||
private readonly _value: BehaviorSubject<T>;
|
||||
public readonly value: Observable<T>;
|
||||
|
||||
public readonly setValue = (value: T): void => {
|
||||
public readonly setValue = (value: T, persist = true): void => {
|
||||
this._value.next(value);
|
||||
localStorage.setItem(this.key, JSON.stringify(value));
|
||||
if (persist) {
|
||||
localStorage.setItem(this.key, JSON.stringify(value));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user