feat(messageLogger): add show diff toggle in the history modal (#934)
* feat(messageLogger): add show diff toggle in the history modal * fix(messageLogger): respect setting --------- Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com> Co-authored-by: creations <creations@creations.works> Co-authored-by: meqativ <meqativ@users.noreply.github.com>
This commit is contained in:
parent
2c96bd198a
commit
8f8901b7e7
2 changed files with 6 additions and 3 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { BaseText } from "@components/BaseText";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { FormSwitch } from "@components/FormSwitch";
|
||||
import { TooltipContainer } from "@components/TooltipContainer";
|
||||
import { classNameFactory } from "@utils/css";
|
||||
import { Margins } from "@utils/margins";
|
||||
|
|
@ -14,7 +15,7 @@ import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, Mod
|
|||
import { findCssClassesLazy } from "@webpack";
|
||||
import { TabBar, Timestamp, useState } from "@webpack/common";
|
||||
|
||||
import { parseEditContent } from ".";
|
||||
import { parseEditContent, settings } from ".";
|
||||
|
||||
const CodeContainerClasses = findCssClassesLazy("markup", "codeContainer");
|
||||
const MiscClasses = findCssClassesLazy("messageContent", "markupRtl");
|
||||
|
|
@ -34,6 +35,7 @@ export function openHistoryModal(message: any) {
|
|||
|
||||
export function HistoryModal({ modalProps, message }: { modalProps: ModalProps; message: any; }) {
|
||||
const [currentTab, setCurrentTab] = useState(message.editHistory.length);
|
||||
const [showDiff, setShowDiff] = useState(settings.store.showEditDiffs);
|
||||
const timestamps = [message.firstEditTimestamp, ...message.editHistory.map(m => m.timestamp)];
|
||||
const contents = [...message.editHistory.map(m => m.content), message.content];
|
||||
|
||||
|
|
@ -45,6 +47,7 @@ export function HistoryModal({ modalProps, message }: { modalProps: ModalProps;
|
|||
</ModalHeader>
|
||||
|
||||
<ModalContent className={cl("contents")}>
|
||||
<FormSwitch title="Show Diff" value={showDiff} onChange={setShowDiff} />
|
||||
<TabBar
|
||||
type="top"
|
||||
look="brand"
|
||||
|
|
@ -86,7 +89,7 @@ export function HistoryModal({ modalProps, message }: { modalProps: ModalProps;
|
|||
</TabBar>
|
||||
|
||||
<div className={classes(CodeContainerClasses.markup, MiscClasses.messageContent, Margins.top20)}>
|
||||
{parseEditContent(contents[currentTab], message, currentTab === contents.length - 1 ? undefined : contents[contents.length - 1])}
|
||||
{parseEditContent(contents[currentTab], message, showDiff ? currentTab === contents.length - 1 ? undefined : contents[contents.length - 1] : undefined)}
|
||||
</div>
|
||||
</ModalContent>
|
||||
</ModalRoot>
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ export function parseEditContent(content: string, message: Message, previousCont
|
|||
});
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
export const settings = definePluginSettings({
|
||||
deleteStyle: {
|
||||
type: OptionType.SELECT,
|
||||
description: "The style of deleted messages",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue