Update PinDMs.plugin.js

This commit is contained in:
Mirco Wittrien 2023-07-25 13:06:08 +02:00
parent 9559055ec8
commit de5f28ca41
1 changed files with 5 additions and 3 deletions

View File

@ -261,7 +261,7 @@ module.exports = (_ => {
onUserContextMenu (e) { onUserContextMenu (e) {
if (e.instance.props.channel && !e.instance.props.channel.guild_id) { if (e.instance.props.channel && !e.instance.props.channel.guild_id) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "close-dm"}); let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "close-dm"});
children.splice(index > -1 ? index : children.length, 0, this.createItem(e.instance.props.channel.id)); children.splice(index > -1 ? index : children.length, 0, this.createItem(e.instance, e.instance.props.channel.id));
} }
} }
@ -269,12 +269,12 @@ module.exports = (_ => {
if (e.instance.props.channel) { if (e.instance.props.channel) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "change-icon", group: true}); let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "change-icon", group: true});
children.splice(index > -1 ? index + 1 : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { children.splice(index > -1 ? index + 1 : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: this.createItem(e.instance.props.channel.id) children: this.createItem(e.instance, e.instance.props.channel.id)
})); }));
} }
} }
createItem (id) { createItem (instance, id) {
if (!id) return; if (!id) return;
let pinnedInGuild = this.isPinnedInGuilds(id); let pinnedInGuild = this.isPinnedInGuilds(id);
@ -314,6 +314,7 @@ module.exports = (_ => {
label: category.name || this.labels.header_pinneddms, label: category.name || this.labels.header_pinneddms,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "pin-channellist", category.id), id: BDFDB.ContextMenuUtils.createItemId(this.name, "pin-channellist", category.id),
action: _ => { action: _ => {
BDFDB.ContextMenuUtils.close(instance);
if (currentCategory) this.removeFromCategory(id, currentCategory, "channelList"); if (currentCategory) this.removeFromCategory(id, currentCategory, "channelList");
this.addToCategory(id, category, "channelList"); this.addToCategory(id, category, "channelList");
} }
@ -326,6 +327,7 @@ module.exports = (_ => {
id: BDFDB.ContextMenuUtils.createItemId(this.name, pinnedInGuild ? "unpin-serverlist" : "pin-serverlist"), id: BDFDB.ContextMenuUtils.createItemId(this.name, pinnedInGuild ? "unpin-serverlist" : "pin-serverlist"),
color: pinnedInGuild ? BDFDB.DiscordConstants.MenuItemColors.DANGER : BDFDB.DiscordConstants.MenuItemColors.DEFAULT, color: pinnedInGuild ? BDFDB.DiscordConstants.MenuItemColors.DANGER : BDFDB.DiscordConstants.MenuItemColors.DEFAULT,
action: _ => { action: _ => {
BDFDB.ContextMenuUtils.close(instance);
if (!pinnedInGuild) this.addPin(id, "guildList"); if (!pinnedInGuild) this.addPin(id, "guildList");
else this.removePin(id, "guildList"); else this.removePin(id, "guildList");
} }