Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
thororen1234 2025-01-25 15:04:52 -05:00
commit b691d21edc
8 changed files with 78 additions and 16 deletions

View file

@ -95,10 +95,9 @@ export default definePlugin({
}
},
{
find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");',
all: true,
find: '"AppCrashedFatalReport: getLastCrash not supported."',
replacement: {
match: /console\.warn\("\[DEPRECATED\] Please use `subscribeWithSelector` middleware"\);/,
match: /console\.log\("AppCrashedFatalReport: getLastCrash not supported\."\);/,
replace: ""
}
},

View file

@ -21,6 +21,7 @@ import { ImageInvisible, ImageVisible } from "@components/Icons";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { ChannelStore } from "@webpack/common";
import { MessageSnapshot } from "@webpack/types";
let style: HTMLStyleElement;
@ -39,7 +40,12 @@ export default definePlugin({
authors: [Devs.Ven],
renderMessagePopoverButton(msg) {
if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length) return null;
// @ts-ignore - discord-types lags behind discord.
const hasAttachmentsInShapshots = msg.messageSnapshots.some(
(snapshot: MessageSnapshot) => snapshot?.message.attachments.length
);
if (!msg.attachments.length && !msg.embeds.length && !msg.stickerItems.length && !hasAttachmentsInShapshots) return null;
const isHidden = hiddenMessages.has(msg.id);

View file

@ -81,7 +81,12 @@ export const settings = definePluginSettings({
});
const imageContextMenuPatch: NavContextMenuPatchCallback = children => {
const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
// Discord re-uses the image context menu for links to for the copy and open buttons
if ("href" in props) return;
// emojis in user statuses
if (props.target?.classList?.contains("emoji")) return;
const { square, nearestNeighbour } = settings.use(["square", "nearestNeighbour"]);
children.push(

View file

@ -215,9 +215,9 @@ export default definePlugin({
},
collapseDeleted: {
type: OptionType.BOOLEAN,
description:
"Whether to collapse deleted messages, similar to blocked messages",
description: "Whether to collapse deleted messages, similar to blocked messages",
default: false,
restartNeeded: true,
},
logEdits: {
type: OptionType.BOOLEAN,

View file

@ -34,6 +34,7 @@ const enum Tabs {
ServerInfo,
Friends,
BlockedUsers,
IgnoredUsers,
MutualMembers
}
@ -47,7 +48,8 @@ interface RelationshipProps extends GuildProps {
const fetched = {
friends: false,
blocked: false
blocked: false,
ignored: false
};
function renderTimestamp(timestamp: number) {
@ -59,11 +61,13 @@ function renderTimestamp(timestamp: number) {
function GuildInfoModal({ guild }: GuildProps) {
const [friendCount, setFriendCount] = useState<number>();
const [blockedCount, setBlockedCount] = useState<number>();
const [ignoredCount, setIgnoredCount] = useState<number>();
const [mutualMembersCount, setMutualMembersCount] = useState<number>();
useEffect(() => {
fetched.friends = false;
fetched.blocked = false;
fetched.ignored = false;
}, []);
const [currentTab, setCurrentTab] = useState(Tabs.ServerInfo);
@ -122,25 +126,55 @@ function GuildInfoModal({ guild }: GuildProps) {
className={cl("tab", { selected: currentTab === Tabs.ServerInfo })}
id={Tabs.ServerInfo}
>
Server Info
<div style={{ textAlign: "center" }}>
<div>
Server Info
</div>
</div>
</TabBar.Item>
<TabBar.Item
className={cl("tab", { selected: currentTab === Tabs.Friends })}
id={Tabs.Friends}
>
Friends{friendCount !== undefined ? ` (${friendCount})` : ""}
<div style={{ textAlign: "center" }}>
<div>
Friends
</div>
{friendCount !== undefined ? ` (${friendCount})` : ""}
</div>
</TabBar.Item>
<TabBar.Item
className={cl("tab", { selected: currentTab === Tabs.MutualMembers })}
id={Tabs.MutualMembers}
>
Mutual Server Members{mutualMembersCount !== undefined ? ` (${mutualMembersCount})` : ""}
<div style={{ textAlign: "center" }}>
<div>
Mutual Users
</div>{mutualMembersCount !== undefined ? ` (${mutualMembersCount})` : ""}
</div>
</TabBar.Item>
<TabBar.Item
className={cl("tab", { selected: currentTab === Tabs.BlockedUsers })}
id={Tabs.BlockedUsers}
>
Blocked Users{blockedCount !== undefined ? ` (${blockedCount})` : ""}
<div style={{ textAlign: "center" }}>
<div>
Blocked Users
</div>
{blockedCount !== undefined ? ` (${blockedCount})` : ""}
</div>
</TabBar.Item>
<TabBar.Item
className={cl("tab", { selected: currentTab === Tabs.IgnoredUsers })}
id={Tabs.IgnoredUsers}
>
<div style={{ textAlign: "center" }}>
<div>
Ignored Users
</div>
{ignoredCount !== undefined ? `(${ignoredCount})` : ""}
</div>
</TabBar.Item>
</TabBar>
@ -149,6 +183,7 @@ function GuildInfoModal({ guild }: GuildProps) {
{currentTab === Tabs.Friends && <FriendsTab guild={guild} setCount={setFriendCount} />}
{currentTab === Tabs.MutualMembers && <MutualMembersTab guild={guild} setCount={setMutualMembersCount} />}
{currentTab === Tabs.BlockedUsers && <BlockedUsersTab guild={guild} setCount={setBlockedCount} />}
{currentTab === Tabs.IgnoredUsers && <IgnoredUserTab guild={guild} setCount={setIgnoredCount} />}
</div>
</div>
);
@ -222,7 +257,13 @@ function BlockedUsersTab({ guild, setCount }: RelationshipProps) {
return UserList("blocked", guild, blockedIds, setCount);
}
function UserList(type: "friends" | "blocked", guild: Guild, ids: string[], setCount: (count: number) => void) {
function IgnoredUserTab({ guild, setCount }: RelationshipProps) {
const ignoredIds = Object.keys(RelationshipStore.getRelationships()).filter(id => RelationshipStore.isIgnored(id));
return UserList("ignored", guild, ignoredIds, setCount);
}
function UserList(type: "friends" | "blocked" | "ignored", guild: Guild, ids: string[], setCount: (count: number) => void) {
const missing = [] as string[];
const members = [] as string[];

View file

@ -21,12 +21,18 @@ import { ImageInvisible, ImageVisible } from "@components/Icons";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { Constants, Menu, PermissionsBits, PermissionStore, RestAPI, UserStore } from "@webpack/common";
import { MessageSnapshot } from "@webpack/types";
const EMBED_SUPPRESSED = 1 << 2;
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, embeds, flags, id: messageId } }) => {
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { channel, message: { author, messageSnapshots, embeds, flags, id: messageId } }) => {
const isEmbedSuppressed = (flags & EMBED_SUPPRESSED) !== 0;
if (!isEmbedSuppressed && !embeds.length) return;
const hasEmbedsInSnapshots = messageSnapshots.some(
(snapshot: MessageSnapshot) => snapshot?.message.embeds.length
);
if (!isEmbedSuppressed && !embeds.length && !hasEmbedsInSnapshots) return;
const hasEmbedPerms = channel.isPrivate() || !!(PermissionStore.getChannelPermissions({ id: channel.id }) & PermissionsBits.EMBED_LINKS);
if (author.id === UserStore.getCurrentUser().id && !hasEmbedPerms) return;

View file

@ -50,6 +50,7 @@ export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore;
export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & {
/** Get the date (as a string) that the relationship was created */
getSince(userId: string): string;
isIgnored(userId: string): boolean;
};
export let EmojiStore: t.EmojiStore;

View file

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Channel, Guild, GuildMember, User } from "discord-types/general";
import { Channel, Guild, GuildMember, Message, User } from "discord-types/general";
import type { ReactNode } from "react";
import { LiteralUnion } from "type-fest";
@ -135,6 +135,10 @@ export type Permissions = "CREATE_INSTANT_INVITE"
export type PermissionsBits = Record<Permissions, bigint>;
export interface MessageSnapshot {
message: Message;
}
export interface Locale {
name: string;
value: string;