mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-11 07:33:05 -04:00
Remove Old Plugins for VC Versions
This commit is contained in:
parent
830d4fb738
commit
55efafdbd0
7 changed files with 0 additions and 320 deletions
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import { isNonNullish } from "@utils/guards";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { waitFor } from "@webpack";
|
||||
import { SnowflakeUtils, Tooltip } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
type FillValue = ("status-danger" | "status-warning" | "text-muted");
|
||||
type Fill = [FillValue, FillValue, FillValue];
|
||||
type DiffKey = keyof Diff;
|
||||
|
||||
interface Diff {
|
||||
days: number,
|
||||
hours: number,
|
||||
minutes: number,
|
||||
seconds: number;
|
||||
}
|
||||
|
||||
let HiddenVisually;
|
||||
waitFor("HiddenVisually", mod => {
|
||||
HiddenVisually = mod.HiddenVisually;
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "MessageLatency",
|
||||
description: "Displays an indicator for messages that took ≥n seconds to send",
|
||||
authors: [EquicordDevs.arHSM],
|
||||
settings: definePluginSettings({
|
||||
latency: {
|
||||
type: OptionType.NUMBER,
|
||||
description: "Threshold in seconds for latency indicator",
|
||||
default: 2
|
||||
}
|
||||
}),
|
||||
patches: [
|
||||
{
|
||||
find: "showCommunicationDisabledStyles",
|
||||
replacement: {
|
||||
match: /(message:(\i),avatar:\i,username:\(0,\i.jsxs\)\(\i.Fragment,\{children:\[)(\i&&)/,
|
||||
replace: "$1$self.Tooltip($2),$3"
|
||||
}
|
||||
}
|
||||
],
|
||||
stringDelta(delta: number) {
|
||||
const diff: Diff = {
|
||||
days: Math.round(delta / (60 * 60 * 24)),
|
||||
hours: Math.round((delta / (60 * 60)) % 24),
|
||||
minutes: Math.round((delta / (60)) % 60),
|
||||
seconds: Math.round(delta % 60),
|
||||
};
|
||||
|
||||
const str = (k: DiffKey) => diff[k] > 0 ? `${diff[k]} ${k}` : null;
|
||||
const keys: DiffKey[] = ["days", "hours", "minutes", "seconds"];
|
||||
|
||||
return keys.map(str).filter(isNonNullish).join(" ");
|
||||
},
|
||||
latencyTooltipData(message: Message) {
|
||||
const { id, nonce } = message;
|
||||
|
||||
// Message wasn't received through gateway
|
||||
if (!isNonNullish(nonce)) return null;
|
||||
|
||||
const delta = Math.round((SnowflakeUtils.extractTimestamp(id) - SnowflakeUtils.extractTimestamp(nonce)) / 1000);
|
||||
|
||||
// Thanks dziurwa (I hate you)
|
||||
// This is when the user's clock is ahead
|
||||
// Can't do anything if the clock is behind
|
||||
const abs = Math.abs(delta);
|
||||
const ahead = abs !== delta;
|
||||
|
||||
const stringDelta = this.stringDelta(abs);
|
||||
|
||||
// Also thanks dziurwa
|
||||
// 2 minutes
|
||||
const TROLL_LIMIT = 2 * 60;
|
||||
const { latency } = this.settings.store;
|
||||
|
||||
const fill: Fill = delta >= TROLL_LIMIT || ahead ? ["text-muted", "text-muted", "text-muted"] : delta >= (latency * 2) ? ["status-danger", "text-muted", "text-muted"] : ["status-warning", "status-warning", "text-muted"];
|
||||
|
||||
return abs >= latency ? { delta: stringDelta, ahead: abs !== delta, fill } : null;
|
||||
},
|
||||
Tooltip(message: Message) {
|
||||
|
||||
const d = this.latencyTooltipData(message);
|
||||
|
||||
if (!isNonNullish(d)) return null;
|
||||
|
||||
return <Tooltip
|
||||
text={d.ahead ? `This user's clock is ${d.delta} ahead` : `This message was sent with a delay of ${d.delta}.`}
|
||||
position="top"
|
||||
>
|
||||
{
|
||||
props => <>
|
||||
{<this.Icon delta={d.delta} fill={d.fill} props={props} />}
|
||||
{/* Time Out indicator uses this, I think this is for a11y */}
|
||||
<HiddenVisually>Delayed Message</HiddenVisually>
|
||||
</>
|
||||
}
|
||||
</Tooltip>;
|
||||
},
|
||||
Icon({ delta, fill, props }: {
|
||||
delta: string;
|
||||
fill: Fill,
|
||||
props: {
|
||||
onClick(): void;
|
||||
onMouseEnter(): void;
|
||||
onMouseLeave(): void;
|
||||
onContextMenu(): void;
|
||||
onFocus(): void;
|
||||
onBlur(): void;
|
||||
"aria-label"?: string;
|
||||
};
|
||||
}) {
|
||||
return <svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
width="12"
|
||||
height="12"
|
||||
role="img"
|
||||
fill="none"
|
||||
style={{ marginRight: "8px", verticalAlign: -1 }}
|
||||
aria-label={delta}
|
||||
aria-hidden="false"
|
||||
{...props}
|
||||
>
|
||||
<path
|
||||
fill={`var(--${fill[0]})`}
|
||||
d="M4.8001 12C4.8001 11.5576 4.51344 11.2 4.16023 11.2H2.23997C1.88676 11.2 1.6001 11.5576 1.6001 12V13.6C1.6001 14.0424 1.88676 14.4 2.23997 14.4H4.15959C4.5128 14.4 4.79946 14.0424 4.79946 13.6L4.8001 12Z"
|
||||
/>
|
||||
<path
|
||||
fill={`var(--${fill[1]})`}
|
||||
d="M9.6001 7.12724C9.6001 6.72504 9.31337 6.39998 8.9601 6.39998H7.0401C6.68684 6.39998 6.40011 6.72504 6.40011 7.12724V13.6727C6.40011 14.0749 6.68684 14.4 7.0401 14.4H8.9601C9.31337 14.4 9.6001 14.0749 9.6001 13.6727V7.12724Z"
|
||||
/>
|
||||
<path
|
||||
fill={`var(--${fill[2]})`}
|
||||
d="M14.4001 2.31109C14.4001 1.91784 14.1134 1.59998 13.7601 1.59998H11.8401C11.4868 1.59998 11.2001 1.91784 11.2001 2.31109V13.6888C11.2001 14.0821 11.4868 14.4 11.8401 14.4H13.7601C14.1134 14.4 14.4001 14.0821 14.4001 13.6888V2.31109Z"
|
||||
/>
|
||||
</svg>;
|
||||
}
|
||||
});
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import "./style.css";
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Timestamp } from "@webpack/common";
|
||||
import type { Message } from "discord-types/general";
|
||||
import type { HTMLAttributes } from "react";
|
||||
|
||||
const { getMessageTimestampId } = findByPropsLazy("getMessageTimestampId");
|
||||
const { calendarFormat, dateFormat, isSameDay } = findByPropsLazy("calendarFormat", "dateFormat", "isSameDay", "accessibilityLabelCalendarFormat");
|
||||
const MessageClasses = findByPropsLazy("separator", "latin24CompactTimeStamp");
|
||||
|
||||
function Sep(props: HTMLAttributes<HTMLElement>) {
|
||||
return <i className={MessageClasses.separator} aria-hidden={true} {...props} />;
|
||||
}
|
||||
|
||||
function ReplyTimestamp({
|
||||
referencedMessage,
|
||||
baseMessage,
|
||||
}: {
|
||||
referencedMessage: { state: number, message?: Message; },
|
||||
baseMessage: Message;
|
||||
}) {
|
||||
if (referencedMessage.state !== 0) return null;
|
||||
const refTimestamp = referencedMessage.message!.timestamp as any;
|
||||
const baseTimestamp = baseMessage.timestamp as any;
|
||||
return (
|
||||
<Timestamp
|
||||
id={getMessageTimestampId(referencedMessage.message)}
|
||||
className="vc-reply-timestamp"
|
||||
compact={isSameDay(refTimestamp, baseTimestamp)}
|
||||
timestamp={refTimestamp}
|
||||
isInline={false}
|
||||
>
|
||||
<Sep>[</Sep>
|
||||
{isSameDay(refTimestamp, baseTimestamp)
|
||||
? dateFormat(refTimestamp, "LT")
|
||||
: calendarFormat(refTimestamp)
|
||||
}
|
||||
<Sep>]</Sep>
|
||||
</Timestamp>
|
||||
);
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "ReplyTimestamp",
|
||||
description: "Shows a timestamp on replied-message previews",
|
||||
authors: [Devs.Kyuuhachi],
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: "renderSingleLineMessage:function()",
|
||||
replacement: {
|
||||
match: /(?<="aria-label":\i,children:\[)(?=\i,\i,\i\])/,
|
||||
replace: "$self.ReplyTimestamp(arguments[0]),"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
ReplyTimestamp: ErrorBoundary.wrap(ReplyTimestamp, { noop: true }),
|
||||
});
|
|
@ -1,3 +0,0 @@
|
|||
.vc-reply-timestamp {
|
||||
margin-right: 0.25em;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import "./style.css";
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "VoiceDownload",
|
||||
description: "Download voice messages.",
|
||||
authors: [EquicordDevs.puv],
|
||||
patches: [
|
||||
{
|
||||
find: ".rippleContainer",
|
||||
replacement: {
|
||||
match: /\(0,i.jsx\).{0,150},children:.{0,50}\("source",{src:(.{1,2})}\)}\)/,
|
||||
replace: "[$&, $self.renderDownload($1)]"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
renderDownload: function (src) {
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<a
|
||||
className="voice-download"
|
||||
href={src}
|
||||
target="_blank"
|
||||
onClick={e => e.stopPropagation()}
|
||||
> <this.Icon /> </a>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
},
|
||||
|
||||
Icon: () => (
|
||||
<svg
|
||||
className="icon"
|
||||
height="24"
|
||||
width="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path
|
||||
d="M12 2a1 1 0 0 1 1 1v10.59l3.3-3.3a1 1 0 1 1 1.4 1.42l-5 5a1 1 0 0 1-1.4 0l-5-5a1 1 0 1 1 1.4-1.42l3.3 3.3V3a1 1 0 0 1 1-1ZM3 20a1 1 0 1 0 0 2h18a1 1 0 1 0 0-2H3Z"
|
||||
/>
|
||||
</svg>
|
||||
),
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
.voice-download {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
color: var(--interactive-normal);
|
||||
margin-left: 12px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.voice-download:hover {
|
||||
color: white;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
# MessageLatency
|
||||
|
||||
Displays an indicator for messages that took ≥n seconds to send.
|
||||
|
||||
> **NOTE**
|
||||
>
|
||||
> - This plugin only applies to messages received after opening the channel
|
||||
> - False positives can exist if the user's system clock has drifted.
|
||||
> - Grouped messages only display latency of the first message
|
||||
|
||||
## Demo
|
||||
|
||||
### Chat View
|
||||
|
||||

|
||||
|
||||
### Clock -ve Drift
|
||||
|
||||

|
||||
|
||||
### Clock +ve Drift
|
||||
|
||||

|
||||
|
||||
### Connection Delay
|
||||
|
||||

|
||||
|
||||
### Icons
|
||||
|
||||

|
|
@ -1,5 +0,0 @@
|
|||
# ReplyTimestamp
|
||||
|
||||
Shows timestamps on the previews of replied-to messages. Pretty simple.
|
||||
|
||||

|
Loading…
Add table
Add a link
Reference in a new issue