fix: regression where RelationshipNotifier errors when CHANNEL_DELETE is dispatched with a partial ChannelRecord

This commit is contained in:
ryan-0324 2024-06-24 20:18:10 -04:00
parent 91aa450ee3
commit 296375a23e
2 changed files with 11 additions and 3 deletions

View file

@ -18,7 +18,7 @@
import { getUniqueUsername, openUserProfile } from "@utils/discord";
import { RelationshipType } from "@vencord/discord-types";
import { UserActionCreators } from "@webpack/common";
import { ChannelStore, UserActionCreators } from "@webpack/common";
import settings from "./settings";
import type { ChannelDeleteAction, GuildDeleteAction, RelationshipRemoveAction } from "./types";
@ -80,7 +80,10 @@ export function onGuildDelete({ guild: { id, unavailable } }: GuildDeleteAction)
export function onChannelDelete({ channel, channel: { id } }: ChannelDeleteAction) {
if (!settings.store.groups) return;
if (!channel.isGroupDM()) return;
if ("isGroupDM" in channel) {
if (!channel.isGroupDM()) return;
} else
if (!ChannelStore.getChannel(id)?.isGroupDM()) return;
if (manuallyRemovedGroupDM === id) {
deleteGroupDM(id);

View file

@ -20,7 +20,12 @@ import type { ChannelRecord } from "@vencord/discord-types";
export interface ChannelDeleteAction {
type: "CHANNEL_DELETE";
channel: ChannelRecord;
channel: ChannelRecord | {
guild_id: string | undefined;
id: string;
parent_id: string | undefined;
};
silent?: boolean;
}
export interface GuildDeleteAction {