mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 07:25:10 +00:00
more fixes
This commit is contained in:
parent
18c0e1d57f
commit
09182add06
3 changed files with 24 additions and 12 deletions
|
@ -13,7 +13,7 @@ import { fetchTimezone, fetchTimezonesBulk, Snowflake } from "./api";
|
|||
import settings, { TimezoneOverwrites } from "./settings";
|
||||
|
||||
// TODO: cache invalidation
|
||||
const TimezoneCache = createStore("TimezoneCache", "TimezoneCache");
|
||||
export const TimezoneCache = createStore("TimezoneCache", "TimezoneCache");
|
||||
|
||||
// A list of callbacks that will trigger on a completed debounced bulk fetch
|
||||
type BulkFetchCallback = (timezone: string | null) => void;
|
||||
|
|
|
@ -153,14 +153,13 @@ export function TimezoneOverrideModal(props: TimezoneOverrideModalProps) {
|
|||
function saveOverwrite() {
|
||||
if (availableTimezones === undefined) return;
|
||||
|
||||
const overwrites: TimezoneOverwrites = settings.store.timezoneOverwrites ?? {};
|
||||
if (timezone === undefined) {
|
||||
const overwrites: TimezoneOverwrites = {
|
||||
[props.userId]: timezone === "NONE" ? null : timezone,
|
||||
...settings.store.timezoneOverwrites,
|
||||
};
|
||||
if (timezone === undefined)
|
||||
delete overwrites[props.userId];
|
||||
} else if (timezone === "NONE") {
|
||||
overwrites[props.userId] = null;
|
||||
} else {
|
||||
overwrites[props.userId] = timezone;
|
||||
}
|
||||
|
||||
settings.store.timezoneOverwrites = overwrites;
|
||||
|
||||
props.modalProps.onClose();
|
||||
|
@ -176,14 +175,19 @@ export function TimezoneOverrideModal(props: TimezoneOverrideModalProps) {
|
|||
|
||||
<ModalContent className="vc-timezone-modal-content">
|
||||
<Text variant="text-md/normal">
|
||||
This override will only be visible locally.
|
||||
This override will only be visible locally and to any synchronized clients via Vencord Cloud.
|
||||
<br />
|
||||
<br />
|
||||
To set your own Timezone for other users to see,
|
||||
click <Link onClick={/* TODO */ _ => _}>here</Link> to
|
||||
authorize TimezoneDB.
|
||||
authorize the public TimezoneDB API.
|
||||
</Text>
|
||||
|
||||
<section className={classes(Margins.bottom16, Margins.top16)}>
|
||||
<Forms.FormTitle tag="h3" className={Margins.top16}>
|
||||
Set Timezone
|
||||
</Forms.FormTitle>
|
||||
|
||||
<section className={classes(Margins.bottom8, Margins.top8)}>
|
||||
<SearchableSelect
|
||||
options={availableTimezones ?? []}
|
||||
value={availableTimezones?.find(opt => opt.value === timezone)}
|
||||
|
|
|
@ -22,9 +22,13 @@ import { IPluginOptionComponentProps, OptionType } from "@utils/types";
|
|||
import { Text } from "@webpack/common";
|
||||
|
||||
import { Snowflake } from "./api";
|
||||
import { DataStore } from "@api/index";
|
||||
import { TimezoneCache } from "./cache";
|
||||
|
||||
export type TimezoneOverwrites = Record<Snowflake, string | null>;
|
||||
|
||||
const DEFAULT_API = "https://timezonedb.catvibers.me/api";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
enableApi: {
|
||||
type: OptionType.BOOLEAN,
|
||||
|
@ -34,7 +38,11 @@ const settings = definePluginSettings({
|
|||
apiUrl: {
|
||||
type: OptionType.STRING,
|
||||
description: "The TimezoneDB API instance to fetch from",
|
||||
default: "https://timezonedb.catvibers.me/api",
|
||||
default: DEFAULT_API,
|
||||
placeholder: DEFAULT_API,
|
||||
onChange(_: any) {
|
||||
DataStore.clear(TimezoneCache).catch(_ => _)
|
||||
}
|
||||
},
|
||||
displayInChat: {
|
||||
type: OptionType.BOOLEAN,
|
||||
|
|
Loading…
Add table
Reference in a new issue