mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Strict types in RemoteConfig
This commit is contained in:
@@ -10,6 +10,7 @@ import { parseIntOrThrow } from './util/parseIntOrThrow';
|
||||
import { SECOND, HOUR } from './util/durations';
|
||||
import * as Bytes from './Bytes';
|
||||
import { uuidToBytes } from './util/uuidToBytes';
|
||||
import { dropNull } from './util/dropNull';
|
||||
import { HashType } from './types/Crypto';
|
||||
import { getCountryCode } from './types/PhoneNumber';
|
||||
|
||||
@@ -54,7 +55,7 @@ type ConfigValueType = {
|
||||
name: ConfigKeyType;
|
||||
enabled: boolean;
|
||||
enabledAt?: number;
|
||||
value?: unknown;
|
||||
value?: string;
|
||||
};
|
||||
export type ConfigMapType = {
|
||||
[key in ConfigKeyType]?: ConfigValueType;
|
||||
@@ -105,7 +106,11 @@ export const refreshRemoteConfig = async (
|
||||
const oldConfig = config;
|
||||
config = newConfig.reduce((acc, { name, enabled, value }) => {
|
||||
const previouslyEnabled: boolean = get(oldConfig, [name, 'enabled'], false);
|
||||
const previousValue: unknown = get(oldConfig, [name, 'value'], undefined);
|
||||
const previousValue: string | undefined = get(
|
||||
oldConfig,
|
||||
[name, 'value'],
|
||||
undefined
|
||||
);
|
||||
// If a flag was previously not enabled and is now enabled,
|
||||
// record the time it was enabled
|
||||
const enabledAt: number | undefined =
|
||||
@@ -115,7 +120,7 @@ export const refreshRemoteConfig = async (
|
||||
name: name as ConfigKeyType,
|
||||
enabled,
|
||||
enabledAt,
|
||||
value,
|
||||
value: dropNull(value),
|
||||
};
|
||||
|
||||
const hasChanged =
|
||||
|
||||
Reference in New Issue
Block a user