Timezones: showLocalTimezone Setting
This commit is contained in:
parent
52a632ae58
commit
1dcb8d9d0f
2 changed files with 13 additions and 4 deletions
2
packages/discord-types/src/components.d.ts
vendored
2
packages/discord-types/src/components.d.ts
vendored
|
|
@ -65,6 +65,8 @@ export interface TooltipProps {
|
||||||
|
|
||||||
tooltipClassName?: string;
|
tooltipClassName?: string;
|
||||||
tooltipContentClassName?: string;
|
tooltipContentClassName?: string;
|
||||||
|
|
||||||
|
delay?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Tooltip = ComponentType<TooltipProps> & {
|
export type Tooltip = ComponentType<TooltipProps> & {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Message, User } from "@vencord/discord-types";
|
import { Message, User } from "@vencord/discord-types";
|
||||||
import { findByPropsLazy, findCssClassesLazy } from "@webpack";
|
import { findByPropsLazy, findCssClassesLazy } from "@webpack";
|
||||||
import { Button, Menu, openModal,showToast, Toasts, Tooltip, useEffect, UserStore, useState } from "@webpack/common";
|
import { Button, Menu, openModal, showToast, Toasts, Tooltip, useEffect, UserStore, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { deleteTimezone, getTimezone, loadDatabaseTimezones, setUserDatabaseTimezone } from "./database";
|
import { deleteTimezone, getTimezone, loadDatabaseTimezones, setUserDatabaseTimezone } from "./database";
|
||||||
import { SetTimezoneModal } from "./TimezoneModal";
|
import { SetTimezoneModal } from "./TimezoneModal";
|
||||||
|
|
@ -84,6 +84,12 @@ export const settings = definePluginSettings({
|
||||||
default: true
|
default: true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showLocalTimezone: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Show Local Timezone instead of just local",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
|
||||||
databaseUrl: {
|
databaseUrl: {
|
||||||
type: OptionType.STRING,
|
type: OptionType.STRING,
|
||||||
description: "Database URL for timezone storage",
|
description: "Database URL for timezone storage",
|
||||||
|
|
@ -195,12 +201,14 @@ const TimestampComponent = ErrorBoundary.wrap(({ userId, timestamp, type }: Prop
|
||||||
|
|
||||||
if (settings.store.showTimezoneInfo) {
|
if (settings.store.showTimezoneInfo) {
|
||||||
const userTimezone = getSystemTimezone();
|
const userTimezone = getSystemTimezone();
|
||||||
if (timezone === userTimezone) {
|
if (timezone === userTimezone && !settings.store.showLocalTimezone) {
|
||||||
displayTime = "local";
|
displayTime = "local";
|
||||||
isLocal = true;
|
isLocal = true;
|
||||||
} else {
|
} else {
|
||||||
const timezoneInfo = getTimezoneAbbreviation(timezone, currentTime);
|
const timezoneInfo = getTimezoneAbbreviation(timezone, currentTime);
|
||||||
displayTime = `${shortTime} ${timezoneInfo || timezone}`;
|
const tz = timezoneInfo || timezone;
|
||||||
|
const hideLocalTime = settings.store.showLocalTimezone && type === "message";
|
||||||
|
displayTime = hideLocalTime ? tz : `${shortTime} ${tz}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,7 +226,6 @@ const TimestampComponent = ErrorBoundary.wrap(({ userId, timestamp, type }: Prop
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
position="top"
|
position="top"
|
||||||
// @ts-ignore
|
|
||||||
delay={750}
|
delay={750}
|
||||||
allowOverflow={false}
|
allowOverflow={false}
|
||||||
spacing={8}
|
spacing={8}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue