This commit is contained in:
Mirco Wittrien 2022-09-27 20:19:49 +02:00
parent 035aaacd78
commit 113a82b4b8
11 changed files with 19 additions and 18 deletions

View File

@ -1097,7 +1097,8 @@ module.exports = (_ => {
libraryCSS = css;
const backupObj = getBackup(dataFileName, dataFilePath);
if (backupObj.backup && backupObj.hashIsSame) parseData(backupObj.backup);
// REMOVE
if (backupObj.backup && backupObj.hashIsSame || true) parseData(backupObj.backup);
else request.get(`https://mwittrien.github.io/BetterDiscordAddons/Library/_res/${dataFileName}`, (e, r, b) => {
if ((e || !b || r.statusCode != 200) && tryAgain) return BDFDB.TimeUtils.timeout(_ => requestLibraryData(), 10000);
if (!e && b && r.statusCode == 200) {
@ -6325,7 +6326,7 @@ module.exports = (_ => {
this.props.guildId = this.props.guild.id;
this.props.selectedChannelId = Internal.LibraryStores.SelectedChannelStore.getChannelId(this.props.guild.id);
let currentVoiceChannel = Internal.LibraryStores.ChannelStore.getChannel(Internal.LibraryStores.RTCConnectionStore.getChannelId());
let currentVoiceChannel = Internal.LibraryStores.ChannelStore.getChannel(Internal.LibraryModules.RTCConnectionUtils.getChannelId());
let hasVideo = currentVoiceChannel && Internal.LibraryStores.SortedVoiceStateStore.hasVideo(currentVoiceChannel);
this.props.selected = this.props.state ? Internal.LibraryStores.SelectedGuildStore.getGuildId() == this.props.guild.id : false;
@ -6338,7 +6339,7 @@ module.exports = (_ => {
screenshare: this.props.state ? !!Internal.LibraryStores.ApplicationStreamingStore.getAllApplicationStreams().filter(stream => stream.guildId == this.props.guild.id)[0] : false,
liveStage: this.props.state ? Object.keys(Internal.LibraryStores.StageInstanceStore.getStageInstancesByGuild(this.props.guild.id)).length > 0 : false,
hasLiveVoiceChannel: this.props.state && false ? !Internal.LibraryStores.UserGuildSettingsStore.isMuted(this.props.guild.id) && BDFDB.ObjectUtils.toArray(Internal.LibraryStores.SortedVoiceStateStore.getVoiceStates(this.props.guild.id)).length > 0 : false,
participating: this.props.state ? Internal.LibraryStores.RTCConnectionStore.getGuildId() == this.props.guild.id : false,
participating: this.props.state ? Internal.LibraryModules.RTCConnectionUtils.getGuildId() == this.props.guild.id : false,
participatingInStage: this.props.state ? currentVoiceChannel && currentVoiceChannel.guild_id == this.props.guild.id && currentVoiceChannel.isGuildStageVoice() : false
});

View File

@ -95,7 +95,7 @@ module.exports = (_ => {
let guild = BDFDB.LibraryStores.GuildStore.getGuild(e.instance.props.guildId);
let channelId = e.instance.props.channelId;
if (!channelId) {
let currentChannelId = BDFDB.LibraryModules.LastChannelStore.getChannelId();
let currentChannelId = BDFDB.LibraryStores.SelectedChannelStore.getChannelId();
channelId = BDFDB.LibraryStores.GuildChannelStore.getSelectableChannelIds(guild.id).indexOf(currentChannelId) > -1 ? currentChannelId : BDFDB.LibraryStores.GuildChannelStore.getDefaultChannel(guild.id).id;
}
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.RoleMention, {

View File

@ -730,7 +730,7 @@ module.exports = (_ => {
changeAppTitle () {
if (this.settings.places.appTitle) {
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId());
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryStores.SelectedChannelStore.getChannelId());
let title = document.head.querySelector("title");
if (title && channel && (document.location.href || "").indexOf(channel.id) > -1 && changedChannels[channel.id] && changedChannels[channel.id].name) {
if (channel.isGroupDM()) BDFDB.DOMUtils.setText(title, this.getGroupName(channel.id));

View File

@ -1346,7 +1346,7 @@ module.exports = (_ => {
}
changeAppTitle () {
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId());
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryStores.SelectedChannelStore.getChannelId());
let title = document.head.querySelector("title");
if (title && channel && channel.isDM() && (document.location.href || "").indexOf(channel.id) > -1) {
let user = BDFDB.LibraryStores.UserStore.getUser(channel.recipients[0]);
@ -1356,7 +1356,7 @@ module.exports = (_ => {
shouldChangeInChat (channelId) {
if (this.settings.types.servers && this.settings.types.dms) return true;
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(channelId || BDFDB.LibraryModules.LastChannelStore.getChannelId());
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(channelId || BDFDB.LibraryStores.SelectedChannelStore.getChannelId());
let isDm = channel && (channel.isDM() || channel.isGroupDM());
if (channel && (this.settings.types.servers && !isDm || this.settings.types.dms && isDm)) return true;
return false;

View File

@ -204,7 +204,7 @@ module.exports = (_ => {
if (!guildId) guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId();
if (!BDFDB.ArrayUtils.is(children) || !user || user.isNonUserBot()) return;
let isGuild = guildId && guildId != BDFDB.DiscordConstants.ME;
guildId = isGuild ? guildId : BDFDB.LibraryModules.LastChannelStore.getChannelId();
guildId = isGuild ? guildId : BDFDB.LibraryStores.SelectedChannelStore.getChannelId();
if (!guildId) return;
if (!loadedUsers[guildId]) loadedUsers[guildId] = {};

View File

@ -225,7 +225,7 @@ module.exports = (_ => {
const channel = BDFDB.LibraryStores.ChannelStore.getChannel(message.channel_id);
const isGroupDM = channel.isGroupDM();
const muted = BDFDB.ChannelUtils.isThread(channel) ? BDFDB.LibraryStores.JoinedThreadsStore.isMuted(channel.id) : BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(guildId, channel.id);
const focused = document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == channel.id;
const focused = document.hasFocus() && BDFDB.LibraryStores.SelectedChannelStore.getChannelId() == channel.id;
if (!guildId && !muted && !(choices[isGroupDM ? "groupdm" : "dm"].focus && focused)) {
this.fireEvent(isGroupDM ? "groupdm" : "dm");
this.playAudio(isGroupDM ? "groupdm" : "dm");

View File

@ -111,7 +111,7 @@ module.exports = (_ => {
}
if (updateData) BDFDB.DataUtils.save(notes, _this, "notes");
let allCount = messages.length;
let currentChannel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()) || {};
let currentChannel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryStores.SelectedChannelStore.getChannelId()) || {};
switch (popoutProps.selectedFilter.value) {
case "channel":
messages = messages.filter(m => m.channel_id == currentChannel.id);

View File

@ -165,14 +165,14 @@ module.exports = (_ => {
}});
let muteTimeout;
let channelId = BDFDB.LibraryStores.RTCConnectionStore.getChannelId();
let connectedUsers = BDFDB.ObjectUtils.filter(BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryStores.RTCConnectionStore.getGuildId()), n => n && n.channelId == channelId && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.userId));
let channelId = BDFDB.LibraryModules.RTCConnectionUtils.getChannelId();
let connectedUsers = BDFDB.ObjectUtils.filter(BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryModules.RTCConnectionUtils.getGuildId()), n => n && n.channelId == channelId && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.userId));
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "playSound", {instead: e => {
let type = e.methodArguments[0];
if (this.settings.notifcations.voiceChat && (type == "disconnect" || type == "user_join" || type == "user_leave" || type == "user_moved")) {
channelId = BDFDB.LibraryStores.RTCConnectionStore.getChannelId();
channelId = BDFDB.LibraryModules.RTCConnectionUtils.getChannelId();
if (channelId) {
let allConnectedUsers = BDFDB.ObjectUtils.filter(BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryStores.RTCConnectionStore.getGuildId()), n => n && n.channelId == channelId);
let allConnectedUsers = BDFDB.ObjectUtils.filter(BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryModules.RTCConnectionUtils.getGuildId()), n => n && n.channelId == channelId);
let unblockedUsers = BDFDB.ObjectUtils.filter(allConnectedUsers, n => n && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.userId));
let unmutedBlockedUsers = BDFDB.ObjectUtils.toArray(allConnectedUsers).filter(n => n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.userId) && !BDFDB.LibraryStores.MediaEngineStore.isLocalMute(n.userId));
if (unmutedBlockedUsers.length) {

View File

@ -355,7 +355,7 @@ module.exports = (_ => {
if (!BDFDB.ArrayUtils.is(children) || !user) return;
let [_, index] = BDFDB.ReactUtils.findParent(children, {props: [["text", [BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER, BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER]]]});
if (index > -1) children[index] = null;
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(config.channelId || BDFDB.LibraryModules.LastChannelStore.getChannelId());
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(config.channelId || BDFDB.LibraryStores.SelectedChannelStore.getChannelId());
let member = channel && this.settings.general.useRoleColor ? (BDFDB.LibraryStores.GuildMemberStore.getMember(channel.guild_id, user.id) || {}) : {};
let fallbackLabel = this.settings.general.useCrown && this.getLabelFallback(userType);
@ -427,7 +427,7 @@ module.exports = (_ => {
getUserType (user, channelId) {
if (!user || this.settings.general.ignoreBots && user.bot || this.settings.general.ignoreMyself && user.id == BDFDB.UserUtils.me.id) return userTypes.NONE;
const channel = BDFDB.LibraryStores.ChannelStore.getChannel(channelId || BDFDB.LibraryModules.LastChannelStore.getChannelId());
const channel = BDFDB.LibraryStores.ChannelStore.getChannel(channelId || BDFDB.LibraryStores.SelectedChannelStore.getChannelId());
if (!channel) return userTypes.NONE;
const guild = BDFDB.LibraryStores.GuildStore.getGuild(channel.guild_id);

View File

@ -888,7 +888,7 @@ module.exports = (_ => {
callback(translation == text ? "" : translation, input, output);
};
let [newText, excepts, translate] = this.removeExceptions(text.trim(), place);
let channelId = BDFDB.LibraryModules.LastChannelStore.getChannelId();
let channelId = BDFDB.LibraryStores.SelectedChannelStore.getChannelId();
let input = Object.assign({}, languages[this.getLanguageChoice(languageTypes.INPUT, place, channelId)]);
let output = Object.assign({}, languages[this.getLanguageChoice(languageTypes.OUTPUT, place, channelId)]);
if (translate && input.id != output.id) {

View File

@ -196,7 +196,7 @@ module.exports = (_ => {
processQuickMessage (e) {
if (!this.settings.places.quickmessage) return;
let input = e.returnvalue.props.inputRef.current;
let channelId = BDFDB.LibraryModules.LastChannelStore.getChannelId();
let channelId = BDFDB.LibraryStores.SelectedChannelStore.getChannelId();
if (this.settings.general.addQuickToggle) e.returnvalue = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
children: [
e.returnvalue,