Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -25,8 +25,8 @@ import RoomAccountSettingsHandler from "./handlers/RoomAccountSettingsHandler";
|
|||
import AccountSettingsHandler from "./handlers/AccountSettingsHandler";
|
||||
import RoomSettingsHandler from "./handlers/RoomSettingsHandler";
|
||||
import ConfigSettingsHandler from "./handlers/ConfigSettingsHandler";
|
||||
import { _t } from '../languageHandler';
|
||||
import dis from '../dispatcher/dispatcher';
|
||||
import { _t } from "../languageHandler";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import { IFeature, ISetting, LabGroup, SETTINGS } from "./Settings";
|
||||
import LocalEchoWrapper from "./handlers/LocalEchoWrapper";
|
||||
import { CallbackFn as WatchCallbackFn, WatchManager } from "./WatchManager";
|
||||
|
@ -144,7 +144,7 @@ export default class SettingsStore {
|
|||
* @returns {string[]} The names of the feature settings.
|
||||
*/
|
||||
public static getFeatureSettingNames(): string[] {
|
||||
return Object.keys(SETTINGS).filter(n => SettingsStore.isFeature(n));
|
||||
return Object.keys(SETTINGS).filter((n) => SettingsStore.isFeature(n));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,8 +178,8 @@ export default class SettingsStore {
|
|||
if (!SettingsStore.doesSettingSupportLevel(originalSettingName, atLevel)) {
|
||||
logger.warn(
|
||||
`Setting handler notified for an update of an invalid setting level: ` +
|
||||
`${originalSettingName}@${atLevel} - this likely means a weird setting value ` +
|
||||
`made it into the level's storage. The notification will be ignored.`,
|
||||
`${originalSettingName}@${atLevel} - this likely means a weird setting value ` +
|
||||
`made it into the level's storage. The notification will be ignored.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -224,18 +224,23 @@ export default class SettingsStore {
|
|||
if (!this.monitors.has(settingName)) this.monitors.set(settingName, new Map());
|
||||
|
||||
const registerWatcher = () => {
|
||||
this.monitors.get(settingName).set(roomId, SettingsStore.watchSetting(
|
||||
settingName, roomId, (settingName, inRoomId, level, newValueAtLevel, newValue) => {
|
||||
dis.dispatch<SettingUpdatedPayload>({
|
||||
action: Action.SettingUpdated,
|
||||
settingName,
|
||||
roomId: inRoomId,
|
||||
level,
|
||||
newValueAtLevel,
|
||||
newValue,
|
||||
});
|
||||
},
|
||||
));
|
||||
this.monitors.get(settingName).set(
|
||||
roomId,
|
||||
SettingsStore.watchSetting(
|
||||
settingName,
|
||||
roomId,
|
||||
(settingName, inRoomId, level, newValueAtLevel, newValue) => {
|
||||
dis.dispatch<SettingUpdatedPayload>({
|
||||
action: Action.SettingUpdated,
|
||||
settingName,
|
||||
roomId: inRoomId,
|
||||
level,
|
||||
newValueAtLevel,
|
||||
newValue,
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const rooms = Array.from(this.monitors.get(settingName).keys());
|
||||
|
@ -245,7 +250,7 @@ export default class SettingsStore {
|
|||
} else {
|
||||
if (roomId === null) {
|
||||
// Unregister all existing watchers and register the new one
|
||||
rooms.forEach(roomId => {
|
||||
rooms.forEach((roomId) => {
|
||||
SettingsStore.unwatchSetting(this.monitors.get(settingName).get(roomId));
|
||||
});
|
||||
this.monitors.get(settingName).clear();
|
||||
|
@ -281,7 +286,7 @@ export default class SettingsStore {
|
|||
public static getDescription(settingName: string): string | ReactNode {
|
||||
const description = SETTINGS[settingName]?.description;
|
||||
if (!description) return null;
|
||||
if (typeof description !== 'string') return description();
|
||||
if (typeof description !== "string") return description();
|
||||
return _t(description);
|
||||
}
|
||||
|
||||
|
@ -307,8 +312,9 @@ export default class SettingsStore {
|
|||
|
||||
public static getBetaInfo(settingName: string): ISetting["betaInfo"] {
|
||||
// consider a beta disabled if the config is explicitly set to false, in which case treat as normal Labs flag
|
||||
if (SettingsStore.isFeature(settingName)
|
||||
&& SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, null, true, true) !== false
|
||||
if (
|
||||
SettingsStore.isFeature(settingName) &&
|
||||
SettingsStore.getValueAt(SettingLevel.CONFIG, settingName, null, true, true) !== false
|
||||
) {
|
||||
return SETTINGS[settingName]?.betaInfo;
|
||||
}
|
||||
|
@ -554,7 +560,7 @@ export default class SettingsStore {
|
|||
throw new Error("Setting '" + settingName + "' does not appear to be a setting.");
|
||||
}
|
||||
|
||||
return level === SettingLevel.DEFAULT || (setting.supportedLevels.includes(level));
|
||||
return level === SettingLevel.DEFAULT || setting.supportedLevels.includes(level);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -636,7 +642,7 @@ export default class SettingsStore {
|
|||
// to show up in a rageshake if required.
|
||||
|
||||
const def = SETTINGS[realSettingName];
|
||||
logger.log(`--- definition: ${def ? JSON.stringify(def) : '<NOT_FOUND>'}`);
|
||||
logger.log(`--- definition: ${def ? JSON.stringify(def) : "<NOT_FOUND>"}`);
|
||||
logger.log(`--- default level order: ${JSON.stringify(LEVEL_ORDER)}`);
|
||||
logger.log(`--- registered handlers: ${JSON.stringify(Object.keys(LEVEL_HANDLERS))}`);
|
||||
|
||||
|
@ -646,9 +652,9 @@ export default class SettingsStore {
|
|||
|
||||
try {
|
||||
const value = handler.getValue(settingName, roomId);
|
||||
logger.log(`--- ${handlerName}@${roomId || '<no_room>'} = ${JSON.stringify(value)}`);
|
||||
logger.log(`--- ${handlerName}@${roomId || "<no_room>"} = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- ${handler}@${roomId || '<no_room>'} THREW ERROR: ${e.message}`);
|
||||
logger.log(`--- ${handler}@${roomId || "<no_room>"} THREW ERROR: ${e.message}`);
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
@ -668,9 +674,9 @@ export default class SettingsStore {
|
|||
|
||||
try {
|
||||
const value = SettingsStore.getValue(settingName, roomId);
|
||||
logger.log(`--- SettingsStore#generic@${roomId || '<no_room>'} = ${JSON.stringify(value)}`);
|
||||
logger.log(`--- SettingsStore#generic@${roomId || "<no_room>"} = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- SettingsStore#generic@${roomId || '<no_room>'} THREW ERROR: ${e.message}`);
|
||||
logger.log(`--- SettingsStore#generic@${roomId || "<no_room>"} THREW ERROR: ${e.message}`);
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
@ -687,9 +693,9 @@ export default class SettingsStore {
|
|||
for (const level of LEVEL_ORDER) {
|
||||
try {
|
||||
const value = SettingsStore.getValueAt(level, settingName, roomId);
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || '<no_room>'} = ${JSON.stringify(value)}`);
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || "<no_room>"} = ${JSON.stringify(value)}`);
|
||||
} catch (e) {
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || '<no_room>'} THREW ERROR: ${e.message}`);
|
||||
logger.log(`--- SettingsStore#${level}@${roomId || "<no_room>"} THREW ERROR: ${e.message}`);
|
||||
logger.error(e);
|
||||
}
|
||||
|
||||
|
@ -732,7 +738,7 @@ export default class SettingsStore {
|
|||
}
|
||||
|
||||
// Always support 'default'
|
||||
if (!handlers['default']) handlers['default'] = LEVEL_HANDLERS['default'];
|
||||
if (!handlers["default"]) handlers["default"] = LEVEL_HANDLERS["default"];
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue