This commit is contained in:
Mirco Wittrien 2020-05-19 17:35:08 +02:00
parent 1a5bd4660d
commit cbc79acf3d
2 changed files with 6 additions and 27 deletions

View File

@ -2400,26 +2400,6 @@
if (info) return BDFDB.ChannelUtils.getData(info.id) || Object.assign(new info.constructor(info), {div:null, instance:null}); if (info) return BDFDB.ChannelUtils.getData(info.id) || Object.assign(new info.constructor(info), {div:null, instance:null});
else return null; else return null;
}; };
BDFDB.ChannelUtils.openMenu = function (eleOrInfoOrId, e = BDFDB.InternalData.mousePosition) {
if (!eleOrInfoOrId) return;
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.ChannelUtils.getId(eleOrInfoOrId) : (typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId);
let channel = LibraryModules.ChannelStore.getChannel(id);
if (channel) {
let type = null;
for (let t in BDFDB.DiscordConstants.ChannelTypes) if (BDFDB.DiscordConstants.ChannelTypes[t] == channel.type) {
type = BDFDB.DiscordConstants.ContextMenuTypes[(t == "GUILD_CATEGORY" ? "CHANNEL_" : "CHANNEL_LIST_") + t.replace("GUILD_", "")];
break;
}
if (type) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.ContextMenus._Exports.ChannelContextMenu && InternalComponents.LibraryComponents.ContextMenus._Exports.ChannelContextMenu.default, Object.assign({}, e, {
type: type,
channel: channel,
guild: LibraryModules.GuildStore.getGuild(channel.guild_id),
selected: channel.id == LibraryModules.LastChannelStore.getChannelId()
}));
});
}
};
BDFDB.ChannelUtils.markAsRead = function (channels) { BDFDB.ChannelUtils.markAsRead = function (channels) {
if (!channels) return; if (!channels) return;
let unreadChannels = []; let unreadChannels = [];
@ -2487,16 +2467,15 @@
let channel = LibraryModules.ChannelStore.getChannel(id); let channel = LibraryModules.ChannelStore.getChannel(id);
if (channel) { if (channel) {
if (channel.isMultiUserDM()) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) { if (channel.isMultiUserDM()) LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.ContextMenus.GroupDMContextMenu, Object.assign({}, e, { return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("GroupDMContextMenu"), Object.assign({}, e, {
channelId: channel.id, channel: channel,
selected: channel.id == LibraryModules.LastChannelStore.getChannelId() selected: channel.id == LibraryModules.LastChannelStore.getChannelId()
})); }));
}, {noBlurEvent: true}); });
else LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) { else LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.ContextMenus._Exports.UserContextMenu && InternalComponents.LibraryComponents.ContextMenus._Exports.UserContextMenu.default, Object.assign({}, e, { return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("DMUserContextMenu"), Object.assign({}, e, {
type: BDFDB.DiscordConstants.ContextMenuTypes.USER_PRIVATE_CHANNELS,
user: LibraryModules.UserStore.getUser(channel.recipients[0]), user: LibraryModules.UserStore.getUser(channel.recipients[0]),
channelId: channel.id, channel: channel,
selected: channel.id == LibraryModules.LastChannelStore.getChannelId() selected: channel.id == LibraryModules.LastChannelStore.getChannelId()
})); }));
}); });

File diff suppressed because one or more lines are too long