refactor: transform FontWater.onAction to switch

This commit is contained in:
Florian Duros 2025-12-22 15:22:18 +01:00
parent fe73a0358c
commit 4119158609
No known key found for this signature in database
GPG key ID: A5BBB4041B493F15

View file

@ -157,23 +157,29 @@ export class FontWatcher implements IWatcher {
}
private onAction = (payload: ActionPayload): void => {
if (payload.action === Action.MigrateBaseFontSize) {
this.migrateBaseFontSize();
} else if (payload.action === Action.UpdateFontSizeDelta) {
this.setRootFontSize(payload.delta);
} else if (payload.action === Action.UpdateSystemFont) {
this.setSystemFont(payload as UpdateSystemFontPayload);
} else if (payload.action === Action.OnLoggedOut) {
// Clear font overrides when logging out
this.setRootFontSize(FontWatcher.DEFAULT_DELTA);
this.setSystemFont({
useBundledEmojiFont: false,
useSystemFont: false,
font: "",
});
} else if (payload.action === Action.OnLoggedIn) {
// Font size can be saved on the account, so grab value when logging in
this.updateFont();
switch (payload.action) {
case Action.MigrateBaseFontSize:
this.migrateBaseFontSize();
break;
case Action.UpdateFontSizeDelta:
this.setRootFontSize(payload.delta);
break;
case Action.UpdateSystemFont:
this.setSystemFont(payload as UpdateSystemFontPayload);
break;
case Action.OnLoggedOut:
// Clear font overrides when logging out
this.setRootFontSize(FontWatcher.DEFAULT_DELTA);
this.setSystemFont({
useBundledEmojiFont: false,
useSystemFont: false,
font: "",
});
break;
case Action.OnLoggedIn:
// Font size can be saved on the account, so grab value when logging in
this.updateFont();
break;
}
};