This commit is contained in:
Mirco Wittrien 2020-10-30 15:54:55 +01:00
parent 5e28e98e54
commit 470b1c3724
2 changed files with 30 additions and 18 deletions

View File

@ -13,13 +13,13 @@ module.exports = (_ => {
"info": {
"name": "BDFDB",
"author": "DevilBro",
"version": "1.0.9",
"version": "1.1.0",
"description": "Give other plugins utility functions"
},
"rawUrl": "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js",
"changeLog": {
"fixed": {
"BD Beta": "Fixed some issues with the beta"
"Crash on Canary": "Fixed the crash issue that occured one some plugins on canary"
}
}
};
@ -2559,14 +2559,13 @@ module.exports = (_ => {
if (unreadChannels.length) BDFDB.ChannelUtils.markAsRead(unreadChannels);
};
BDFDB.GuildUtils.rerenderAll = function (instant) {
return;
BDFDB.TimeUtils.clear(GuildsRerenderTimeout);
GuildsRerenderTimeout = BDFDB.TimeUtils.timeout(_ => {
let GuildsIns = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"Guilds", unlimited:true});
let GuildsPrototype = BDFDB.ObjectUtils.get(GuildsIns, "_reactInternalFiber.type.prototype");
if (GuildsIns && GuildsPrototype) {
BDFDB.PatchUtils.patch(BDFDB, GuildsPrototype, "render", {after: e => {
e.returnValue.props.children = [];
e.returnValue.props.children = typeof e.returnValue.props.children == "function" ? (_ => {return null;}) : [];
BDFDB.ReactUtils.forceUpdate(GuildsIns);
}}, {once: true});
BDFDB.ReactUtils.forceUpdate(GuildsIns);
@ -2693,7 +2692,7 @@ module.exports = (_ => {
let ChannelsPrototype = BDFDB.ObjectUtils.get(ChannelsIns, "_reactInternalFiber.type.prototype");
if (ChannelsIns && ChannelsPrototype) {
BDFDB.PatchUtils.patch(BDFDB, ChannelsPrototype, "render", {after: e => {
e.returnValue.props.children = [];
e.returnValue.props.children = typeof e.returnValue.props.children == "function" ? (_ => {return null;}) : [];
BDFDB.ReactUtils.forceUpdate(ChannelsIns);
}}, {once: true});
BDFDB.ReactUtils.forceUpdate(ChannelsIns);

View File

@ -13,12 +13,12 @@ module.exports = (_ => {
"info": {
"name": "EditChannels",
"author": "DevilBro",
"version": "4.1.7",
"version": "4.1.8",
"description": "Allow you to rename and recolor channelnames"
},
"changeLog": {
"fixed": {
"Autocomplete Menu": "Works again"
"Works again": "Yas"
}
}
};
@ -77,8 +77,8 @@ module.exports = (_ => {
AuditLog: "render",
SettingsInvites: "render",
HeaderBarContainer: "render",
ChannelCategoryItem: "render",
ChannelItem: "render",
ChannelCategoryItem: "default",
ChannelItem: "default",
QuickSwitchChannelResult: "render",
MessageContent: "type"
},
@ -86,8 +86,8 @@ module.exports = (_ => {
AutocompleteChannelResult: "render",
AuditLog: "render",
HeaderBarContainer: "render",
ChannelCategoryItem: "render",
ChannelItem: "render",
ChannelCategoryItem: "default",
ChannelItem: "default",
QuickSwitchChannelResult: "render",
RecentsChannelHeader: "default"
}
@ -174,12 +174,13 @@ module.exports = (_ => {
}
}
forceUpdateAll () {
forceUpdateAll (instant = false) {
changedChannels = BDFDB.DataUtils.load(this, "channels");
settings = BDFDB.DataUtils.get(this, "settings");
this.changeAppTitle();
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.ChannelUtils.rerenderAll(instant);
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"Channel", unlimited:true}));
}
@ -205,7 +206,7 @@ module.exports = (_ => {
disabled: !changedChannels[e.instance.props.channel.id],
action: _ => {
BDFDB.DataUtils.remove(this, "channels", e.instance.props.channel.id);
this.forceUpdateAll();
this.forceUpdateAll(true);
}
})
]
@ -290,9 +291,15 @@ module.exports = (_ => {
if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
else {
let onMouseEnter = e.returnvalue.props.onMouseEnter || ( _ => {});
e.returnvalue.props.onMouseEnter = event => {e.instance.setState({hovered: true});};
e.returnvalue.props.onMouseEnter = event => {
onMouseEnter(event);
e.instance.setState({hovered: true});
};
let onMouseLeave = e.returnvalue.props.onMouseLeave || ( _ => {});
e.returnvalue.props.onMouseLeave = event => {e.instance.setState({hovered: false});};
e.returnvalue.props.onMouseLeave = event => {
onMouseLeave(event);
e.instance.setState({hovered: false});
};
let modify = BDFDB.ObjectUtils.extract(Object.assign({}, e.instance.props, e.instance.state), "muted", "locked", "selected", "unread", "connected", "hovered");
let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.categoryname]]});
if (categoryName) this.changeChannelColor(categoryName, e.instance.props.channel.id, modify);
@ -307,9 +314,15 @@ module.exports = (_ => {
if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
else {
let onMouseEnter = e.returnvalue.props.onMouseEnter || ( _ => {});
e.returnvalue.props.onMouseEnter = event => {e.instance.setState({hovered: true});};
e.returnvalue.props.onMouseEnter = event => {
onMouseEnter(event);
e.instance.setState({hovered: true});
};
let onMouseLeave = e.returnvalue.props.onMouseLeave || ( _ => {});
e.returnvalue.props.onMouseLeave = event => {e.instance.setState({hovered: false});};
e.returnvalue.props.onMouseLeave = event => {
onMouseLeave(event);
e.instance.setState({hovered: false});
};
let modify = BDFDB.ObjectUtils.extract(Object.assign({}, e.instance.props, e.instance.state), "muted", "locked", "selected", "unread", "connected", "hovered");
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.channelname]]});
if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify);
@ -543,7 +556,7 @@ module.exports = (_ => {
let changed = false;
if (Object.keys(data).every(key => data[key] == null || data[key] == false) && (changed = true)) BDFDB.DataUtils.remove(this, "channels", channel.id);
else if (!BDFDB.equals(oldData, data) && (changed = true)) BDFDB.DataUtils.save(data, this, "channels", channel.id);
if (changed) this.forceUpdateAll();
if (changed) this.forceUpdateAll(true);
}
}]
});