Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #60 from verticalsync/dev
Browse files Browse the repository at this point in the history
Fix crash issues
  • Loading branch information
verticalsync authored Feb 13, 2024
2 parents 3e9c583 + 748d470 commit cac25e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/plugins/replyTimestamp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "./style.css";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Timestamp } from "@webpack/common";
import { LegacyTimestamp } from "@webpack/common";
import { Message } from "discord-types/general";
import { HTMLAttributes } from "react";

Expand Down Expand Up @@ -46,11 +46,11 @@ export default definePlugin({
if (referencedMessage.state === 0) {
const refTimestamp = referencedMessage.message!.timestamp;
const baseTimestamp = baseMessage.timestamp;
return <Timestamp
return <LegacyTimestamp
id={MessageIds.getMessageTimestampId(referencedMessage.message)}
className="c98-reply-timestamp"
compact={refTimestamp.isSame(baseTimestamp, "date")}
timestamp={refTimestamp.toDate()}
timestamp={refTimestamp}
isInline={false}
>
<Sep>[</Sep>
Expand All @@ -59,7 +59,7 @@ export default definePlugin({
: DateUtils.calendarFormat(refTimestamp)
}
<Sep>]</Sep>
</Timestamp>;
</LegacyTimestamp>;
}
},
});
6 changes: 3 additions & 3 deletions src/plugins/soundBoardLogger/components/UserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { openUserProfile } from "@utils/discord";
import { Margins } from "@utils/margins";
import { classes, copyWithToast } from "@utils/misc";
import { closeModal, ModalContent, ModalRoot, openModal } from "@utils/modal";
import { Clickable, Forms, Text, Timestamp } from "@webpack/common";
import moment from "moment";
import { Clickable, Forms, LegacyTimestamp, Text } from "@webpack/common";

import { AvatarStyles, cl, downloadAudio, getEmojiUrl, playSound, SoundLogEntry, User, UserSummaryItem } from "../utils";
import { DownloadIcon, IconWithTooltip, PlayIcon } from "./Icons";
Expand Down Expand Up @@ -65,7 +64,8 @@ export default function UserModal({ item, user, sounds, closeModal }: { item: So
<Flex flexDirection="column" style={{ gap: "7px", height: "68px", justifyContent: "space-between" }}>
<Text variant="text-md/bold" style={{ height: "20px" }}>{item.soundId}</Text>
<Text variant="text-md/normal">Played {currentUser.plays.length} {currentUser.plays.length === 1 ? "time" : "times"}.</Text>
<Text variant="text-md/normal">Last played: <Timestamp timestamp={moment(currentUser.plays.at(-1)).toDate()} /></Text>
{/* @ts-ignore */}
<Text variant="text-md/normal">Last played: <LegacyTimestamp timestamp={moment(currentUser.plays.at(-1))} /></Text>
</Flex>
</Flex>
<Text variant="heading-lg/semibold" tag="h2" className={classes(Margins.top16, Margins.bottom8)}>
Expand Down
1 change: 1 addition & 0 deletions src/webpack/common/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export let useToken: t.useToken;

export const MaskedLink = waitForComponent<t.MaskedLink>("MaskedLink", m => m?.type?.toString().includes("MASKED_LINK)"));
export const Timestamp = waitForComponent<t.Timestamp>("Timestamp", filters.byCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format"));
export const LegacyTimestamp = waitForComponent<t.LegacyTimestamp>("Timestamp", filters.byCode(".Messages.MESSAGE_EDITED_TIMESTAMP_A11Y_LABEL.format"));
export const Flex = waitForComponent<t.Flex>("Flex", ["Justify", "Align", "Wrap"]);

export const { OAuth2AuthorizeModal } = findByPropsLazy("OAuth2AuthorizeModal");
Expand Down
14 changes: 14 additions & 0 deletions src/webpack/common/types/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import moment from "moment";
import type { ComponentType, CSSProperties, FunctionComponent, HtmlHTMLAttributes, HTMLProps, KeyboardEvent, MouseEvent, PropsWithChildren, PropsWithRef, ReactNode, Ref } from "react";

export type TextVariant = "heading-sm/normal" | "heading-sm/medium" | "heading-sm/semibold" | "heading-sm/bold" | "heading-md/normal" | "heading-md/medium" | "heading-md/semibold" | "heading-md/bold" | "heading-lg/normal" | "heading-lg/medium" | "heading-lg/semibold" | "heading-lg/bold" | "heading-xl/normal" | "heading-xl/medium" | "heading-xl/bold" | "heading-xxl/normal" | "heading-xxl/medium" | "heading-xxl/bold" | "eyebrow" | "heading-deprecated-14/normal" | "heading-deprecated-14/medium" | "heading-deprecated-14/bold" | "text-xxs/normal" | "text-xxs/medium" | "text-xxs/semibold" | "text-xxs/bold" | "text-xs/normal" | "text-xs/medium" | "text-xs/semibold" | "text-xs/bold" | "text-sm/normal" | "text-sm/medium" | "text-sm/semibold" | "text-sm/bold" | "text-md/normal" | "text-md/medium" | "text-md/semibold" | "text-md/bold" | "text-lg/normal" | "text-lg/medium" | "text-lg/semibold" | "text-lg/bold" | "display-sm" | "display-md" | "display-lg" | "code";
Expand Down Expand Up @@ -165,6 +166,19 @@ export type Timestamp = ComponentType<PropsWithChildren<{
isVisibleOnlyOnHover?: boolean;
}>>;

export type LegacyTimestamp = ComponentType<PropsWithChildren<{
timestamp: moment.Moment;
isEdited?: boolean;

className?: string;
id?: string;

cozyAlt?: boolean;
compact?: boolean;
isInline?: boolean;
isVisibleOnlyOnHover?: boolean;
}>>;

export type TextInput = ComponentType<PropsWithChildren<{
name?: string;
onChange?(value: string, name?: string): void;
Expand Down

0 comments on commit cac25e0

Please sign in to comment.