This commit is contained in:
Mirco Wittrien 2022-09-27 21:28:54 +02:00
parent 90b6e7e4d2
commit a46fefafcb
9 changed files with 28 additions and 28 deletions

View File

@ -3282,7 +3282,7 @@ module.exports = (_ => {
return Internal.LibraryModules.IconUtils.getGuildBannerURL(guild).split("?")[0];
};
BDFDB.GuildUtils.getFolder = function (id) {
return Internal.LibraryStores.SortedGuildStore.guildFolders.filter(n => n.folderId).find(n => n.guildIds.includes(id));
return Internal.LibraryModules.SortedGuildUtils.guildFolders.filter(n => n.folderId).find(n => n.guildIds.includes(id));
};
BDFDB.GuildUtils.openMenu = function (guild, e = mousePosition) {
if (!guild) return;
@ -3318,7 +3318,7 @@ module.exports = (_ => {
return BDFDB.ReactUtils.findValue(div, "folderId", {up: true});
};
BDFDB.FolderUtils.getDefaultName = function (folderId) {
let folder = Internal.LibraryStores.SortedGuildStore.getGuildFolderById(folderId);
let folder = Internal.LibraryModules.SortedGuildUtils.getGuildFolderById(folderId);
if (!folder) return "";
let rest = 2 * Internal.DiscordConstants.MAX_GUILD_FOLDER_NAME_LENGTH;
let names = [], allNames = folder.guildIds.map(guildId => (Internal.LibraryStores.GuildStore.getGuild(guildId) || {}).name).filter(n => n);
@ -7101,7 +7101,7 @@ module.exports = (_ => {
return BDFDB.ReactUtils.createElement(Internal.LibraryComponents.Flex, {
className: this.props.className,
wrap: Internal.LibraryComponents.Flex.Wrap.WRAP,
children: [this.props.includeDMs && {name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES, acronym: "DMs", id: Internal.DiscordConstants.ME, getIconURL: _ => {}}].concat(Internal.LibraryStores.SortedGuildStore.getFlattenedGuilds()).filter(n => n).map(guild => BDFDB.ReactUtils.createElement(Internal.LibraryComponents.TooltipContainer, {
children: [this.props.includeDMs && {name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES, acronym: "DMs", id: Internal.DiscordConstants.ME, getIconURL: _ => {}}].concat(Internal.LibraryModules.SortedGuildUtils.getFlattenedGuilds()).filter(n => n).map(guild => BDFDB.ReactUtils.createElement(Internal.LibraryComponents.TooltipContainer, {
text: guild.name,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(this.props.guildClassName, BDFDB.disCN.settingsguild, this.props.disabled.includes(guild.id) && BDFDB.disCN.settingsguilddisabled),

View File

@ -137,7 +137,7 @@ module.exports = (_ => {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.QuerySearchUtils, "queryChannels", {after: e => {
if (!e.methodArguments[0].query) return;
for (let id of BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuildIds().map(id => Object.keys(BDFDB.LibraryStores.ChannelStore.getMutableGuildChannelsForGuild(id))).flat()) {
for (let id of BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuildIds().map(id => Object.keys(BDFDB.LibraryStores.ChannelStore.getMutableGuildChannelsForGuild(id))).flat()) {
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(id);
if (channel && !channel.isCategory()) {
let category = channel.parent_id && BDFDB.LibraryStores.ChannelStore.getChannel(channel.parent_id);

View File

@ -271,7 +271,7 @@ module.exports = (_ => {
}
getGuildFromRoleId (roleId) {
return BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuilds().find(g => g.roles[roleId]);
return BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuilds().find(g => g.roles[roleId]);
}
changeRolesInGuild (guild, useNative) {
@ -300,7 +300,7 @@ module.exports = (_ => {
BDFDB.DataUtils.remove(this, "roles", id);
}
else {
for (let guild of BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuilds()) if (cachedRoles[guild.id]) guild.roles = cachedRoles[guild.id];
for (let guild of BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuilds()) if (cachedRoles[guild.id]) guild.roles = cachedRoles[guild.id];
cachedRoles = {};
BDFDB.DataUtils.remove(this, "roles");
}

View File

@ -161,7 +161,7 @@ module.exports = (_ => {
else return item[data.key];
}
})),
data: BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuilds().map((guild, i) => {
data: BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuilds().map((guild, i) => {
let itemData = {
index: i,
guild: guild,

View File

@ -761,7 +761,7 @@ module.exports = (_ => {
}
getStatusWithMobileAndActivity (id, config, clientStatuses) {
let voiceState = BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuildIds().map(BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates).map(BDFDB.ObjectUtils.toArray).flat(10).find(n => n.selfStream & n.userId == id && BDFDB.LibraryStores.ChannelStore.getChannel(n.channelId) && BDFDB.UserUtils.can("VIEW_CHANNEL", BDFDB.UserUtils.me.id, n.channelId));
let voiceState = BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuildIds().map(BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates).map(BDFDB.ObjectUtils.toArray).flat(10).find(n => n.selfStream & n.userId == id && BDFDB.LibraryStores.ChannelStore.getChannel(n.channelId) && BDFDB.UserUtils.can("VIEW_CHANNEL", BDFDB.UserUtils.me.id, n.channelId));
let status = {
name: BDFDB.UserUtils.getStatus(id),
activity: null,

View File

@ -69,7 +69,7 @@ module.exports = (_ => {
BDFDB.GuildUtils.markAsRead(guildIds.filter(id => id && !blacklist.includes(id)));
}
getGuilds() {
return BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuilds().map(g => g.id).filter(n => n);
return BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuilds().map(g => g.id).filter(n => n);
}
getUnread() {
return this.getGuilds().filter(id => BDFDB.LibraryStores.GuildReadStateStore.hasUnread(id) || BDFDB.LibraryStores.GuildReadStateStore.getMentionCount(id) > 0);
@ -314,7 +314,7 @@ module.exports = (_ => {
batchSetGuilds (settingsPanel, collapseStates, value) {
if (!value) {
for (let id of BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuildIds()) blacklist.push(id);
for (let id of BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuildIds()) blacklist.push(id);
this.saveBlacklist(BDFDB.ArrayUtils.removeCopies(blacklist));
}
else this.saveBlacklist([]);

View File

@ -79,7 +79,7 @@ module.exports = (_ => {
className: BDFDB.disCNS.guildouter + BDFDB.disCN._servercounterservercountwrap,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.guildslabel + BDFDB.disCN._servercounterservercount,
children: `${BDFDB.LanguageUtils.LanguageStrings.SERVERS}  ${BDFDB.LibraryStores.SortedGuildStore.getFlattenedGuildIds().length}`
children: `${BDFDB.LanguageUtils.LanguageStrings.SERVERS}  ${BDFDB.LibraryModules.SortedGuildUtils.getFlattenedGuildIds().length}`
})
}));
}

View File

@ -85,7 +85,7 @@ module.exports = (_ => {
render() {
let closing = this.props.closing;
delete this.props.closing;
let folders = Array.from(BDFDB.LibraryStores.ExpandedGuildFolderStore.getExpandedFolders()).map(folderId => BDFDB.LibraryStores.SortedGuildStore.getGuildFolderById(folderId)).filter(folder => folder && folder.guildIds);
let folders = Array.from(BDFDB.LibraryStores.ExpandedGuildFolderStore.getExpandedFolders()).map(folderId => BDFDB.LibraryModules.SortedGuildUtils.getGuildFolderById(folderId)).filter(folder => folder && folder.guildIds);
this.props.folders = folders.length || closing ? folders : (this.props.folders || []);
BDFDB.TimeUtils.clear(this._rerenderTimeout);
if (!folders.length && this.props.folders.length && !closing) this._rerenderTimeout = BDFDB.TimeUtils.timeout(_ => {
@ -576,9 +576,9 @@ module.exports = (_ => {
onGuildContextMenu (e) {
if (document.querySelector(BDFDB.dotCN.modalwrapper)) return;
if (e.instance.props.guild) {
let folders = BDFDB.LibraryStores.SortedGuildStore.guildFolders.filter(n => n.folderId);
let folders = BDFDB.LibraryModules.SortedGuildUtils.guildFolders.filter(n => n.folderId);
let folder = BDFDB.GuildUtils.getFolder(e.instance.props.guild.id);
let unfolderedGuilds = BDFDB.LibraryStores.SortedGuildStore.getSortedGuilds().filter(n => !n.folderId).map(n => n.guilds[0]).filter(n => n);
let unfolderedGuilds = BDFDB.LibraryModules.SortedGuildUtils.getSortedGuilds().filter(n => !n.folderId).map(n => n.guilds[0]).filter(n => n);
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
@ -617,7 +617,7 @@ module.exports = (_ => {
onGuildFolderContextMenu (e) {
if (document.querySelector(BDFDB.dotCN.modalwrapper)) return;
if (e.instance.props.target && e.instance.props.folderId) {
let folder = BDFDB.LibraryStores.SortedGuildStore.getGuildFolderById(e.instance.props.folderId);
let folder = BDFDB.LibraryModules.SortedGuildUtils.getGuildFolderById(e.instance.props.folderId);
let data = this.getFolderConfig(e.instance.props.folderId);
let muted = data.muteFolder && folder.guildIds.every(guildid => BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(guildid));
if (data.muteFolder != muted) {
@ -683,7 +683,7 @@ module.exports = (_ => {
if (topBar) {
let topIsVisible = topBar.props.isVisible;
topBar.props.isVisible = BDFDB.TimeUtils.suppress((...args) => {
let ids = BDFDB.LibraryStores.SortedGuildStore.guildFolders.filter(n => n.folderId).map(n => n.guildIds).flat(10);
let ids = BDFDB.LibraryModules.SortedGuildUtils.guildFolders.filter(n => n.folderId).map(n => n.guildIds).flat(10);
args[2] = args[2].filter(id => !ids.includes(id));
return topIsVisible(...args) || BDFDB.LibraryStores.GuildReadStateStore.getMentionCount(args[0]) == 0;
}, "Error in isVisible of Top Bar in Guild List!");
@ -692,7 +692,7 @@ module.exports = (_ => {
if (bottomBar) {
let bottomIsVisible = bottomBar.props.isVisible;
bottomBar.props.isVisible = BDFDB.TimeUtils.suppress((...args) => {
let ids = BDFDB.LibraryStores.SortedGuildStore.guildFolders.filter(n => n.folderId).map(n => n.guildIds).flat(10);
let ids = BDFDB.LibraryModules.SortedGuildUtils.guildFolders.filter(n => n.folderId).map(n => n.guildIds).flat(10);
args[2] = args[2].filter(id => !ids.includes(id));
return bottomIsVisible(...args) || BDFDB.LibraryStores.GuildReadStateStore.getMentionCount(args[0]) == 0;
}, "Error in isVisible of Bottom Bar in Guild List!");
@ -813,7 +813,7 @@ module.exports = (_ => {
BDFDB.DOMUtils.removeClass(root, BDFDB.disCN.modalsmall);
}
if (e.returnvalue) {
let folder = BDFDB.LibraryStores.SortedGuildStore.getGuildFolderById(e.instance.props.folderId);
let folder = BDFDB.LibraryModules.SortedGuildUtils.getGuildFolderById(e.instance.props.folderId);
let data = this.getFolderConfig(e.instance.props.folderId);
let newData = Object.assign({}, data, {folderName: folder.folderName});
@ -990,7 +990,7 @@ module.exports = (_ => {
generateId (prefix) {
if (prefix == "folder") {
let id = Math.floor(Math.random() * 4294967296);
return BDFDB.LibraryStores.SortedGuildStore.guildFolders.every(n => !n.folderId || n.folderId != id) ? id : this.generateId(prefix);
return BDFDB.LibraryModules.SortedGuildUtils.guildFolders.every(n => !n.folderId || n.folderId != id) ? id : this.generateId(prefix);
}
else {
let data = BDFDB.DataUtils.load(this, prefix + "s");
@ -1010,7 +1010,7 @@ module.exports = (_ => {
}
getFolderConfig (folderId) {
let folder = BDFDB.LibraryStores.SortedGuildStore.getGuildFolderById(folderId) || {};
let folder = BDFDB.LibraryModules.SortedGuildUtils.getGuildFolderById(folderId) || {};
let data = folderConfigs[folderId] || {
iconID: "-1",
muteFolder: false,
@ -1099,7 +1099,7 @@ module.exports = (_ => {
}
updateFolder (folder) {
let oldGuildFolders = [].concat(BDFDB.LibraryStores.SortedGuildStore.guildFolders), guildFolders = [], guildPositions = [];
let oldGuildFolders = [].concat(BDFDB.LibraryModules.SortedGuildUtils.guildFolders), guildFolders = [], guildPositions = [];
for (let oldFolder of oldGuildFolders) {
if (oldFolder.folderId == folder.folderId) guildFolders.push(Object.assign({}, oldFolder, folder));
else guildFolders.push(oldFolder);
@ -1112,7 +1112,7 @@ module.exports = (_ => {
if (!guildIds) return;
guildIds = [guildIds].flat(10);
if (!guildIds.length) return;
let oldGuildFolders = [].concat(BDFDB.LibraryStores.SortedGuildStore.guildFolders), guildFolders = [], guildPositions = [], added = false;
let oldGuildFolders = [].concat(BDFDB.LibraryModules.SortedGuildUtils.guildFolders), guildFolders = [], guildPositions = [], added = false;
for (let oldFolder of oldGuildFolders) {
if (!oldFolder.folderId && guildIds.includes(oldFolder.guildIds[0])) {
if (!added) {
@ -1130,7 +1130,7 @@ module.exports = (_ => {
}
removeFolder (folderId) {
let oldGuildFolders = [].concat(BDFDB.LibraryStores.SortedGuildStore.guildFolders), guildFolders = [], guildPositions = [];
let oldGuildFolders = [].concat(BDFDB.LibraryModules.SortedGuildUtils.guildFolders), guildFolders = [], guildPositions = [];
for (let oldFolder of oldGuildFolders) {
if (oldFolder.folderId == folderId) {
for (let guildId of oldFolder.guildIds) guildFolders.push({guildIds: [guildId]});
@ -1142,7 +1142,7 @@ module.exports = (_ => {
}
addGuildToFolder (folderId, guildId) {
let oldGuildFolders = [].concat(BDFDB.LibraryStores.SortedGuildStore.guildFolders), guildFolders = [], guildPositions = [];
let oldGuildFolders = [].concat(BDFDB.LibraryModules.SortedGuildUtils.guildFolders), guildFolders = [], guildPositions = [];
for (let oldFolder of oldGuildFolders) {
if (oldFolder.folderId) {
let newFolder = Object.assign({}, oldFolder);
@ -1157,7 +1157,7 @@ module.exports = (_ => {
}
removeGuildFromFolder (folderId, guildId) {
let oldGuildFolders = [].concat(BDFDB.LibraryStores.SortedGuildStore.guildFolders), guildFolders = [], guildPositions = [];
let oldGuildFolders = [].concat(BDFDB.LibraryModules.SortedGuildUtils.guildFolders), guildFolders = [], guildPositions = [];
for (let oldFolder of oldGuildFolders) {
if (oldFolder.folderId == folderId) {
let newFolder = Object.assign({}, oldFolder);

View File

@ -80,7 +80,7 @@ module.exports = (_ => {
if (e.methodArguments[0].type == "STREAMER_MODE_UPDATE") BDFDB.GuildUtils.rerenderAll(true);
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.SortedGuildStore, "getGuildFolderById", {after: e => {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SortedGuildUtils, "getGuildFolderById", {after: e => {
let hiddenGuildIds = hiddenEles.servers || [];
if (e.returnValue && hiddenGuildIds.length) {
let folder = Object.assign({}, e.returnValue);
@ -220,8 +220,8 @@ module.exports = (_ => {
let hiddenGuildIds = hiddenEles && hiddenEles.servers || [];
let hiddenFolderIds = hiddenEles && hiddenEles.folders || [];
let guilds = BDFDB.LibraryStores.SortedGuildStore.guildFolders.map(n => n.guildIds).flat(10).map(guildId => BDFDB.LibraryStores.GuildStore.getGuild(guildId)).filter(n => n);
let folders = BDFDB.LibraryStores.SortedGuildStore.guildFolders.filter(n => n.folderId);
let guilds = BDFDB.LibraryModules.SortedGuildUtils.guildFolders.map(n => n.guildIds).flat(10).map(guildId => BDFDB.LibraryStores.GuildStore.getGuild(guildId)).filter(n => n);
let folders = BDFDB.LibraryModules.SortedGuildUtils.guildFolders.filter(n => n.folderId);
let foldersAdded = [];
BDFDB.ModalUtils.open(this, {