mirror of
https://github.com/Equicord/Equicord.git
synced 2025-01-30 19:23:29 -05:00
Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
ef174a9a8b
7 changed files with 75 additions and 33 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "equicord",
|
"name": "equicord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.10.9",
|
"version": "1.11.0",
|
||||||
"description": "The other cutest Discord client mod",
|
"description": "The other cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Equicord/Equicord#readme",
|
"homepage": "https://github.com/Equicord/Equicord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
@ -122,4 +122,4 @@
|
||||||
"node": ">=18",
|
"node": ">=18",
|
||||||
"pnpm": ">=9"
|
"pnpm": ">=9"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,7 +31,7 @@ export default definePlugin({
|
||||||
replace: (_, rest1, rest2, args) => "" +
|
replace: (_, rest1, rest2, args) => "" +
|
||||||
`${rest1}async ${rest2}` +
|
`${rest1}async ${rest2}` +
|
||||||
`if(await Vencord.Api.MessageEvents._handlePreEdit(${args}))` +
|
`if(await Vencord.Api.MessageEvents._handlePreEdit(${args}))` +
|
||||||
"return Promise.resolve({shouldClear:true,shouldRefocus:true});"
|
"return Promise.resolve({shouldClear:false,shouldRefocus:true});"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -39,12 +39,12 @@ export default definePlugin({
|
||||||
replacement: {
|
replacement: {
|
||||||
// props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply);
|
// props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply);
|
||||||
// Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid)
|
// Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid)
|
||||||
match: /(\((\{openWarningPopout:.{0,200}?\})\)\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)/,
|
match: /(\{openWarningPopout:.{0,100}type:this.props.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)(?<=\)\(({.+?})\)\.then.+?)/,
|
||||||
// props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true };
|
// props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true };
|
||||||
replace: (_, rest1, extra, rest2, parsedMessage, channel, replyOptions) => "" +
|
replace: (_, rest1, extra, rest2, parsedMessage, channel, replyOptions) => "" +
|
||||||
`${rest1}async ${rest2}` +
|
`${rest1}async ${rest2}` +
|
||||||
`if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` +
|
`if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` +
|
||||||
"return{shouldClear:true,shouldRefocus:true};"
|
"return{shouldClear:false,shouldRefocus:true};"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,16 +9,11 @@ import "./style.css";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Timestamp } from "@webpack/common";
|
import { DateUtils, Timestamp } from "@webpack/common";
|
||||||
import type { Message } from "discord-types/general";
|
import type { Message } from "discord-types/general";
|
||||||
import type { HTMLAttributes } from "react";
|
import type { HTMLAttributes } from "react";
|
||||||
|
|
||||||
const { calendarFormat, dateFormat, isSameDay } = mapMangledModuleLazy("millisecondsInUnit:", {
|
|
||||||
calendarFormat: filters.byCode("sameElse"),
|
|
||||||
dateFormat: filters.byCode('":'),
|
|
||||||
isSameDay: filters.byCode("Math.abs(+"),
|
|
||||||
});
|
|
||||||
const MessageClasses = findByPropsLazy("separator", "latin24CompactTimeStamp");
|
const MessageClasses = findByPropsLazy("separator", "latin24CompactTimeStamp");
|
||||||
|
|
||||||
function Sep(props: HTMLAttributes<HTMLElement>) {
|
function Sep(props: HTMLAttributes<HTMLElement>) {
|
||||||
|
@ -46,14 +41,14 @@ function ReplyTimestamp({
|
||||||
return (
|
return (
|
||||||
<Timestamp
|
<Timestamp
|
||||||
className="vc-reply-timestamp"
|
className="vc-reply-timestamp"
|
||||||
compact={isSameDay(refTimestamp, baseTimestamp)}
|
compact={DateUtils.isSameDay(refTimestamp, baseTimestamp)}
|
||||||
timestamp={refTimestamp}
|
timestamp={refTimestamp}
|
||||||
isInline={false}
|
isInline={false}
|
||||||
>
|
>
|
||||||
<Sep>[</Sep>
|
<Sep>[</Sep>
|
||||||
{isSameDay(refTimestamp, baseTimestamp)
|
{DateUtils.isSameDay(refTimestamp, baseTimestamp)
|
||||||
? dateFormat(refTimestamp, "LT")
|
? DateUtils.dateFormat(refTimestamp, "LT")
|
||||||
: calendarFormat(refTimestamp)
|
: DateUtils.calendarFormat(refTimestamp)
|
||||||
}
|
}
|
||||||
<Sep>]</Sep>
|
<Sep>]</Sep>
|
||||||
</Timestamp>
|
</Timestamp>
|
||||||
|
|
|
@ -16,12 +16,28 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "./styles.css";
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Flex } from "@components/Flex";
|
import { classNameFactory } from "@api/Styles";
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { RelationshipStore } from "@webpack/common";
|
import { DateUtils, RelationshipStore, Text, TooltipContainer } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
import { PropsWithChildren } from "react";
|
||||||
|
|
||||||
|
const formatter = new Intl.DateTimeFormat(undefined, {
|
||||||
|
month: "numeric",
|
||||||
|
day: "numeric",
|
||||||
|
year: "numeric",
|
||||||
|
});
|
||||||
|
|
||||||
|
const cl = classNameFactory("vc-sortFriendRequests-");
|
||||||
|
|
||||||
|
function getSince(user: User) {
|
||||||
|
return new Date(RelationshipStore.getSince(user.id));
|
||||||
|
}
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showDates: {
|
showDates: {
|
||||||
|
@ -48,28 +64,27 @@ export default definePlugin({
|
||||||
find: "#{intl::FRIEND_REQUEST_CANCEL}",
|
find: "#{intl::FRIEND_REQUEST_CANCEL}",
|
||||||
replacement: {
|
replacement: {
|
||||||
predicate: () => settings.store.showDates,
|
predicate: () => settings.store.showDates,
|
||||||
match: /subText:(\i)(?<=user:(\i).+?)/,
|
match: /(?<=\.listItemContents,children:\[)\(0,.+?(?=,\(0)(?<=user:(\i).+?)/,
|
||||||
replace: (_, subtext, user) => `subText:$self.makeSubtext(${subtext},${user})`
|
replace: (children, user) => `$self.WrapperDateComponent({user:${user},children:${children}})`
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
wrapSort(comparator: Function, row: any) {
|
wrapSort(comparator: Function, row: any) {
|
||||||
return row.type === 3 || row.type === 4
|
return row.type === 3 || row.type === 4
|
||||||
? -this.getSince(row.user)
|
? -getSince(row.user)
|
||||||
: comparator(row);
|
: comparator(row);
|
||||||
},
|
},
|
||||||
|
|
||||||
getSince(user: User) {
|
WrapperDateComponent: ErrorBoundary.wrap(({ user, children }: PropsWithChildren<{ user: User; }>) => {
|
||||||
return new Date(RelationshipStore.getSince(user.id));
|
const since = getSince(user);
|
||||||
},
|
|
||||||
|
|
||||||
makeSubtext(text: string, user: User) {
|
return <div className={cl("wrapper")}>
|
||||||
const since = this.getSince(user);
|
{children}
|
||||||
return (
|
{!isNaN(since.getTime()) && (
|
||||||
<Flex flexDirection="column" style={{ gap: 0, flexWrap: "wrap", lineHeight: "0.9rem" }}>
|
<TooltipContainer text={DateUtils.dateFormat(since, "LLLL")} tooltipClassName={cl("tooltip")}>
|
||||||
<span>{text}</span>
|
<Text variant="text-xs/normal" className={cl("date")}>{formatter.format(since)}</Text>
|
||||||
{!isNaN(since.getTime()) && <span>Received — {since.toDateString()}</span>}
|
</TooltipContainer>
|
||||||
</Flex>
|
)}
|
||||||
);
|
</div>;
|
||||||
}
|
})
|
||||||
});
|
});
|
||||||
|
|
18
src/plugins/sortFriendRequests/styles.css
Normal file
18
src/plugins/sortFriendRequests/styles.css
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
.vc-sortFriendRequests-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
margin-right: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-sortFriendRequests-tooltip {
|
||||||
|
max-width: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-sortFriendRequests-date {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-family: var(--font-code);
|
||||||
|
}
|
7
src/webpack/common/types/utils.d.ts
vendored
7
src/webpack/common/types/utils.d.ts
vendored
|
@ -326,3 +326,10 @@ export interface DisplayProfileUtils {
|
||||||
getDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
|
getDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
|
||||||
useDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
|
useDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DateUtils {
|
||||||
|
isSameDay(date1: Date, date2: Date): boolean;
|
||||||
|
calendarFormat(date: Date): string;
|
||||||
|
dateFormat(date: Date, format: string): string;
|
||||||
|
diffAsUnits(start: Date, end: Date, stopAtOneSecond?: boolean): Record<"days" | "hours" | "minutes" | "seconds", number>;
|
||||||
|
}
|
||||||
|
|
|
@ -205,3 +205,10 @@ export const DisplayProfileUtils: t.DisplayProfileUtils = mapMangledModuleLazy(/
|
||||||
getDisplayProfile: filters.byCode(".getGuildMemberProfile("),
|
getDisplayProfile: filters.byCode(".getGuildMemberProfile("),
|
||||||
useDisplayProfile: filters.byCode(/\[\i\.\i,\i\.\i],\(\)=>/)
|
useDisplayProfile: filters.byCode(/\[\i\.\i,\i\.\i],\(\)=>/)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const DateUtils: t.DateUtils = mapMangledModuleLazy("millisecondsInUnit:", {
|
||||||
|
calendarFormat: filters.byCode("sameElse"),
|
||||||
|
dateFormat: filters.byCode('":'),
|
||||||
|
isSameDay: filters.byCode("Math.abs(+"),
|
||||||
|
diffAsUnits: filters.byCode("days:0", "millisecondsInUnit")
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue