This commit is contained in:
rushiiMachine 2024-06-23 22:50:37 -07:00
parent 1b145a5695
commit 9b64d9b033
No known key found for this signature in database
GPG key ID: DCBE5952BB3B6420
3 changed files with 16 additions and 21 deletions

View file

@ -58,15 +58,17 @@ function LocalTimestampInner(props: LocalTimestampProps): JSX.Element | null {
const longTime = formatTimestamp(timezone, timestamp, true); const longTime = formatTimestamp(timezone, timestamp, true);
const shortTime = formatTimestamp(timezone, timestamp, false); const shortTime = formatTimestamp(timezone, timestamp, false);
if (props.type === "message" && !shortTime)
return null;
const shortTimeFormatted = props.type === "message" const shortTimeFormatted = props.type === "message"
? `${shortTime}` ? `${shortTime}`
: shortTime; : shortTime ?? "Error";
const classes = props.type === "message" const classes = props.type === "message"
? `timezone-message-item ${messageClasses.timestamp}` ? `timezone-message-item ${messageClasses.timestamp}`
: "timezone-profile-item"; : "timezone-profile-item";
return <> return <>
<Tooltip <Tooltip
position="top" position="top"
@ -76,6 +78,7 @@ function LocalTimestampInner(props: LocalTimestampProps): JSX.Element | null {
spacing={8} spacing={8}
hideOnClick={true} hideOnClick={true}
tooltipClassName="timezone-tooltip" tooltipClassName="timezone-tooltip"
hide={!longTime}
text={longTime} text={longTime}
> >
{toolTipProps => <> {toolTipProps => <>

View file

@ -6,6 +6,7 @@
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { UserStore } from "@webpack/common";
import { Message, User } from "discord-types/general"; import { Message, User } from "discord-types/general";
import { LocalTimestamp } from "./components"; import { LocalTimestamp } from "./components";
@ -30,23 +31,6 @@ export default definePlugin({
], ],
patches: [ patches: [
// {
// find: "copyMetaData:\"User Tag\"",
// replacement: {
// match: /return(\(0.+?}\)}\)]}\))}/,
// replace: "return [$1, $self.getProfileTimezonesComponent(arguments[0])] }",
// },
// },
// {
// // TODO: fix this
// // thank you https://github.com/Syncxv/vc-timezones/blob/master/index.tsx for saving me from painful work
// find: ".badgesContainer,{",
// replacement: {
// match: /id:\(0,\i\.getMessageTimestampId\)\(\i\),timestamp.{1,50}}\),/,
// replace: "$&,$self.getTimezonesComponent(arguments[0]),",
// },
// },
// Based on Syncxv's vc-timezones user plugin // // Based on Syncxv's vc-timezones user plugin //
...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({ ...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({
find, find,
@ -76,6 +60,7 @@ export default definePlugin({
renderMessageTimezone: (props?: { message?: Message; }) => { renderMessageTimezone: (props?: { message?: Message; }) => {
if (!settings.store.displayInChat || !props?.message) return null; if (!settings.store.displayInChat || !props?.message) return null;
if (UserStore.getCurrentUser().id === props?.message?.id) return null;
return <LocalTimestamp return <LocalTimestamp
userId={props.message.author.id} userId={props.message.author.id}

View file

@ -1,15 +1,22 @@
/** Based on Syncxv's vc-timezones user plugin **/ /** Based on Syncxv's vc-timezones user plugin **/
.timezone-profile-item { .timezone-profile-item {
display: flex;
position: absolute; position: absolute;
right: 0; right: 0;
bottom: 0; bottom: 0;
margin: 28px 16px 4px; margin: 28px 14px 10px;
background: var(--profile-body-background-color, var(--background-primary)); background: var(--profile-body-background-color, var(--background-primary));
border-radius: 4px; border-radius: 4px;
padding: 0.25rem 0.5rem; padding: 0.25rem 0.5rem;
font-size: 0.75rem; font-size: 0.75rem;
color: var(--text-normal); color: var(--text-normal);
cursor: pointer;
transition: all 0.2s ease-in-out;
&:hover {
filter: brightness(130%);
}
} }
[class*="topSection"] .timezone-profile-item { [class*="topSection"] .timezone-profile-item {