mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +00:00
rename overwrites to overrides
This commit is contained in:
parent
35e937678b
commit
6768e22e53
3 changed files with 23 additions and 23 deletions
|
@ -10,7 +10,7 @@ import { debounce } from "@shared/debounce";
|
|||
import { Logger } from "@utils/Logger";
|
||||
|
||||
import { fetchTimezone, fetchTimezonesBulk, Snowflake } from "./api";
|
||||
import settings, { TimezoneOverwrites } from "./settings";
|
||||
import settings, { TimezoneOverrides } from "./settings";
|
||||
|
||||
// TODO: cache invalidation
|
||||
export const TimezoneCache = createStore("TimezoneCache", "TimezoneCache");
|
||||
|
@ -54,9 +54,9 @@ export async function getUserTimezone(
|
|||
immediate: boolean = false,
|
||||
force: boolean = false,
|
||||
): Promise<string | null> {
|
||||
const overwrites: TimezoneOverwrites = settings.store.timezoneOverwrites ?? {};
|
||||
const overwrite = overwrites[userId];
|
||||
if (overwrite !== undefined) return overwrite;
|
||||
const overrides: TimezoneOverrides = settings.store.timezoneOverrides ?? {};
|
||||
const override = overrides[userId];
|
||||
if (override !== undefined) return override;
|
||||
if (!settings.store.enableApi) return null;
|
||||
|
||||
if (!force) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import { SelectOption } from "@webpack/types";
|
|||
|
||||
import { Snowflake } from "./api";
|
||||
import { getUserTimezone } from "./cache";
|
||||
import settings, { TimezoneOverwrites } from "./settings";
|
||||
import settings, { TimezoneOverrides } from "./settings";
|
||||
import { formatTimestamp, getTimezonesLazy } from "./utils";
|
||||
|
||||
// Based on Syncxv's vc-timezones user plugin //
|
||||
|
@ -99,7 +99,7 @@ function LocalTimestampInner(props: LocalTimestampProps): JSX.Element | null {
|
|||
className={classes}
|
||||
onClick={() => {
|
||||
toolTipProps.onClick();
|
||||
openTimezoneOverwriteModal(props.userId);
|
||||
openTimezoneOverrideModal(props.userId);
|
||||
}}>
|
||||
{shortTimeFormatted}
|
||||
</span>
|
||||
|
@ -113,7 +113,7 @@ interface TimezoneOverrideModalProps {
|
|||
modalProps: ModalProps,
|
||||
}
|
||||
|
||||
function TimezoneOverrideModal(props: TimezoneOverrideModalProps) {
|
||||
function SetTimezoneOverrideModal(props: TimezoneOverrideModalProps) {
|
||||
const [availableTimezones, setAvailableTimezones] = useState<SelectOption[]>();
|
||||
const [timezone, setTimezone] = useState<string | "NONE" | undefined>();
|
||||
|
||||
|
@ -140,22 +140,22 @@ function TimezoneOverrideModal(props: TimezoneOverrideModalProps) {
|
|||
setAvailableTimezones(options);
|
||||
});
|
||||
|
||||
const overwrites: TimezoneOverwrites = settings.store.timezoneOverwrites ?? {};
|
||||
const overwrite = overwrites[props.userId];
|
||||
setTimezone(overwrite === null ? "NONE" : overwrite);
|
||||
const overrides: TimezoneOverrides = settings.store.timezoneOverrides ?? {};
|
||||
const override = overrides[props.userId];
|
||||
setTimezone(override === null ? "NONE" : override);
|
||||
}, []);
|
||||
|
||||
function saveOverwrite() {
|
||||
function saveOverride() {
|
||||
if (availableTimezones === undefined) return;
|
||||
|
||||
const overwrites: TimezoneOverwrites = {
|
||||
const overrides: TimezoneOverrides = {
|
||||
[props.userId]: timezone === "NONE" ? null : timezone,
|
||||
...settings.store.timezoneOverwrites,
|
||||
...settings.store.timezoneOverrides,
|
||||
};
|
||||
if (timezone === undefined)
|
||||
delete overwrites[props.userId];
|
||||
delete overrides[props.userId];
|
||||
|
||||
settings.store.timezoneOverwrites = overwrites;
|
||||
settings.store.timezoneOverrides = overrides;
|
||||
|
||||
props.modalProps.onClose();
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ function TimezoneOverrideModal(props: TimezoneOverrideModalProps) {
|
|||
<Button
|
||||
color={Button.Colors.BRAND}
|
||||
disabled={availableTimezones === undefined}
|
||||
onClick={saveOverwrite}>
|
||||
onClick={saveOverride}>
|
||||
Save
|
||||
</Button>
|
||||
<Button color={Button.Colors.RED} onClick={props.modalProps.onClose}>
|
||||
|
@ -208,10 +208,10 @@ function TimezoneOverrideModal(props: TimezoneOverrideModalProps) {
|
|||
</ModalRoot>;
|
||||
}
|
||||
|
||||
export function openTimezoneOverwriteModal(userId: string) {
|
||||
export function openTimezoneOverrideModal(userId: string) {
|
||||
openModal(modalProps => <>
|
||||
<ErrorBoundary>
|
||||
<TimezoneOverrideModal userId={userId} modalProps={modalProps} />
|
||||
<SetTimezoneOverrideModal userId={userId} modalProps={modalProps} />
|
||||
</ErrorBoundary>
|
||||
</>);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import { Text } from "@webpack/common";
|
|||
import { Snowflake } from "./api";
|
||||
import { TimezoneCache } from "./cache";
|
||||
|
||||
export type TimezoneOverwrites = Record<Snowflake, string | null>;
|
||||
export type TimezoneOverrides = Record<Snowflake, string | null>;
|
||||
|
||||
const DEFAULT_API = "https://timezonedb.catvibers.me/api";
|
||||
|
||||
|
@ -54,11 +54,11 @@ const settings = definePluginSettings({
|
|||
description: "Show local time in user profiles",
|
||||
default: true,
|
||||
},
|
||||
timezoneOverwrites: {
|
||||
timezoneOverrides: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "Local overwrites for users' timezones",
|
||||
description: "Local overrides for users' timezones",
|
||||
component: props => <>
|
||||
<TimezoneOverwritesSetting
|
||||
<TimezoneOverridesSetting
|
||||
setValue={props.setValue}
|
||||
setError={props.setError}
|
||||
option={props.option} />
|
||||
|
@ -84,6 +84,6 @@ export function SettingsComponent(): JSX.Element {
|
|||
</>;
|
||||
}
|
||||
|
||||
function TimezoneOverwritesSetting(props: IPluginOptionComponentProps): JSX.Element {
|
||||
function TimezoneOverridesSetting(props: IPluginOptionComponentProps): JSX.Element {
|
||||
return <></>;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue