mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Tidy settings
This commit is contained in:
@@ -70,10 +70,17 @@ export class Config {
|
|||||||
|
|
||||||
private applyConfigToSettings(): void {
|
private applyConfigToSettings(): void {
|
||||||
if (!this.config) return;
|
if (!this.config) return;
|
||||||
// only the value from config if it hasn't been overridden
|
// use the value from config if it hasn't been overridden
|
||||||
if (showNonMemberTiles.value === undefined) {
|
const showNonMemberTilesSubscription = showNonMemberTiles.value.subscribe(
|
||||||
showNonMemberTiles.setValue(this.config.show_non_member_tiles);
|
(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;
|
public config?: ResolvedConfigOptions;
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ export const SettingsModal: FC<Props> = ({
|
|||||||
id="showNonMemberTiles"
|
id="showNonMemberTiles"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
label={t("settings.show_non_member_tiles")}
|
label={t("settings.show_non_member_tiles")}
|
||||||
checked={showNonMemberTiles}
|
checked={!!showNonMemberTiles}
|
||||||
onChange={useCallback(
|
onChange={useCallback(
|
||||||
(event: ChangeEvent<HTMLInputElement>): void => {
|
(event: ChangeEvent<HTMLInputElement>): void => {
|
||||||
setShowNonMemberTiles(event.target.checked);
|
setShowNonMemberTiles(event.target.checked);
|
||||||
|
|||||||
@@ -37,9 +37,11 @@ export class Setting<T> {
|
|||||||
private readonly _value: BehaviorSubject<T>;
|
private readonly _value: BehaviorSubject<T>;
|
||||||
public readonly value: Observable<T>;
|
public readonly value: Observable<T>;
|
||||||
|
|
||||||
public readonly setValue = (value: T): void => {
|
public readonly setValue = (value: T, persist = true): void => {
|
||||||
this._value.next(value);
|
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