mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 14:13:01 -04:00
fix auth cancel, add fist run toast, fix label, add default to sys timezone when showing if nothing at all is set
This commit is contained in:
parent
3fbc993950
commit
aac513cf44
3 changed files with 42 additions and 4 deletions
|
@ -29,9 +29,12 @@ export function SetTimezoneModal({ userId, modalProps, database }: { userId: str
|
|||
settings.store.useDatabase &&
|
||||
(settings.store.preferDatabaseOverLocal || !localTimezone);
|
||||
|
||||
setCurrentValue(shouldUseDatabase ? getTimezone(userId) ?? localTimezone : localTimezone);
|
||||
}, [userId, settings.store.useDatabase, settings.store.preferDatabaseOverLocal]);
|
||||
const value = shouldUseDatabase
|
||||
? getTimezone(userId) ?? localTimezone
|
||||
: localTimezone;
|
||||
|
||||
setCurrentValue(value ?? Intl.DateTimeFormat().resolvedOptions().timeZone);
|
||||
}, [userId, settings.store.useDatabase, settings.store.preferDatabaseOverLocal]);
|
||||
|
||||
const options = useMemo(() => {
|
||||
return Intl.supportedValuesOf("timeZone").map(timezone => {
|
||||
|
|
|
@ -82,6 +82,8 @@ export function authModal(callback?: () => void) {
|
|||
permissions={0n}
|
||||
cancelCompletesFlow={false}
|
||||
callback={async (res: any) => {
|
||||
if (!res || !res.location) return;
|
||||
|
||||
try {
|
||||
const url = new URL(res.location);
|
||||
|
||||
|
@ -99,6 +101,7 @@ export function authModal(callback?: () => void) {
|
|||
showToast("Authorization successful!", Toasts.Type.SUCCESS);
|
||||
callback?.();
|
||||
} catch (e) {
|
||||
console.error("Error during authorization:", e);
|
||||
showToast("Unexpected error during authorization", Toasts.Type.FAILURE);
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -93,6 +93,13 @@ export const settings = definePluginSettings({
|
|||
Reset Database Timezones
|
||||
</Button>
|
||||
)
|
||||
},
|
||||
|
||||
askedTimezone: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Whether the user has been asked to set their timezone",
|
||||
hidden: true,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -181,10 +188,9 @@ const TimestampComponent = ErrorBoundary.wrap(({ userId, timestamp, type }: Prop
|
|||
const userContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: { user: User; }) => {
|
||||
if (user?.id == null) return;
|
||||
|
||||
const label = settings.store.useDatabase ? "Set Local Timezone" : "Set Timezone";
|
||||
const setTimezoneItem = (
|
||||
<Menu.MenuItem
|
||||
label={label}
|
||||
label="Set Local Timezone"
|
||||
id="set-timezone"
|
||||
action={() => openModal(modalProps => <SetTimezoneModal userId={user.id} modalProps={modalProps} />)}
|
||||
/>
|
||||
|
@ -248,6 +254,32 @@ export default definePlugin({
|
|||
|
||||
if (settings.store.useDatabase) {
|
||||
await loadDatabaseTimezones();
|
||||
|
||||
const userSysTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
if (!settings.store.askedTimezone && userSysTimezone) {
|
||||
showToast(
|
||||
"",
|
||||
Toasts.Type.MESSAGE,
|
||||
{
|
||||
duration: 10000,
|
||||
component: (
|
||||
<Button
|
||||
color={Button.Colors.GREEN}
|
||||
onClick={() => {
|
||||
authModal(async () => {
|
||||
openModal(modalProps => <SetTimezoneModal userId={UserStore.getCurrentUser().id} modalProps={modalProps} database={true} />);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Want to save your timezone to the database? Click here to set it.
|
||||
</Button>
|
||||
),
|
||||
position: Toasts.Position.BOTTOM
|
||||
}
|
||||
);
|
||||
settings.store.askedTimezone = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue