From 11a4ca227e3eb6e48a37fe27fe866f5ba28ed710 Mon Sep 17 00:00:00 2001 From: ArjixWasTaken <53124886+ArjixWasTaken@users.noreply.github.com> Date: Sun, 19 Feb 2023 14:34:17 +0200 Subject: [PATCH] feat: edit the timezone of a user for now this is just temporarily changing the timezone, nothing gets changed in the DB just for testing purposes --- src/plugins/Timezones/Utils.ts | 5 +- src/plugins/Timezones/all_timezones.ts | 1 + src/plugins/Timezones/index.tsx | 88 +++++++++++++++++++++----- 3 files changed, 76 insertions(+), 18 deletions(-) diff --git a/src/plugins/Timezones/Utils.ts b/src/plugins/Timezones/Utils.ts index b3ca58e3e..9387719c7 100644 --- a/src/plugins/Timezones/Utils.ts +++ b/src/plugins/Timezones/Utils.ts @@ -19,6 +19,7 @@ const PreloadedUserSettings = findLazy(m => m.ProtoClass?.typeName === "discord_protos.discord_users.v1.PreloadedUserSettings"); import * as DataStore from "@api/DataStore"; +import { VENCORD_USER_AGENT } from "@utils/constants"; import { debounce } from "@utils/debounce"; import { findLazy } from "@webpack"; export const DATASTORE_KEY = "plugins.Timezones.savedTimezones"; @@ -48,10 +49,10 @@ async function bulkFetchTimezones(ids: string[]): Promise(); + const [isInEditMode, setIsInEditMode] = React.useState(false); + const forceUpdate = useForceUpdater(); React.useEffect(() => { getUserTimezone(user.id).then(timezone => setTimezone(timezone)); + + setInterval(forceUpdate, 1000); }, [user.id]); if (!Vencord.Settings.plugins.Timezones.showTimezonesInProfile) { return null; } - // thank you arjix very cool return ( - { - return console.log("ahhh!"); - // TODO create a modal to set timezone and make text clickable h - }} style={{ - alignItems: "center", - // make it clickable - cursor: "pointer", - }}> - {(timezone) ? getTimeString(timezone) : "Click to set timezone"} - + {!isInEditMode && { + if (timezone) { + Toasts.show({ + type: Toasts.Type.MESSAGE, + message: timezone, + id: Toasts.genId() + }); + } + }}>{(timezone) ? getTimeString(timezone) : "No timezone set"}} + + {isInEditMode && ( + +