UBR v1.0.9
This commit is contained in:
parent
e1ecad65d7
commit
cd113940e5
|
@ -1,4 +1,7 @@
|
||||||
# [UnreadBadgesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=UnreadBadgesRedux "UnreadBadgesRedux") Changelog
|
# [UnreadBadgesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=UnreadBadgesRedux "UnreadBadgesRedux") Changelog
|
||||||
|
### 1.0.9
|
||||||
|
- Fixed not working on channels.
|
||||||
|
|
||||||
### 1.0.8
|
### 1.0.8
|
||||||
- Fixed not working on channels.
|
- Fixed not working on channels.
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports = (() => {
|
||||||
twitter_username: ''
|
twitter_username: ''
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
version: '1.0.8',
|
version: '1.0.9',
|
||||||
description: 'Adds a number badge to server icons and channels.',
|
description: 'Adds a number badge to server icons and channels.',
|
||||||
github: 'https://github.com/1Lighty',
|
github: 'https://github.com/1Lighty',
|
||||||
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/UnreadBadgesRedux/UnreadBadgesRedux.plugin.js'
|
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/UnreadBadgesRedux/UnreadBadgesRedux.plugin.js'
|
||||||
|
@ -50,7 +50,7 @@ module.exports = (() => {
|
||||||
{
|
{
|
||||||
title: 'fixed',
|
title: 'fixed',
|
||||||
type: 'fixed',
|
type: 'fixed',
|
||||||
items: ['Fixed not working on channels.']
|
items: ['Fixed not working on channels, again.']
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
defaultConfig: [
|
defaultConfig: [
|
||||||
|
@ -311,13 +311,10 @@ module.exports = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async patchChannelItem(promiseState) {
|
async patchChannelItem(promiseState) {
|
||||||
const selector = `.${XenoLib.getSingleClass('modeUnread wrapper', true)}`;
|
const TextChannel = await ReactComponents.getComponentByName('TextChannel', `.${XenoLib.getSingleClass('mentionsBadge containerDefault')}`);
|
||||||
const ChannelItem = await ReactComponents.getComponentByName('ChannelItem', selector);
|
|
||||||
if (!ChannelItem.selector) ChannelItem.selector = selector;
|
|
||||||
if (promiseState.cancelled) return;
|
if (promiseState.cancelled) return;
|
||||||
const settings = this.settings;
|
const settings = this.settings;
|
||||||
const MentionsBadgeClassname = XenoLib.getClass('iconVisibility mentionsBadge');
|
const MentionsBadgeClassname = XenoLib.getClass('iconVisibility mentionsBadge');
|
||||||
const IconsChildren = XenoLib.getClass('modeMuted children');
|
|
||||||
function UnreadBadge(e) {
|
function UnreadBadge(e) {
|
||||||
const unreadCount = StoresModule.useStateFromStores([UnreadStore], () => {
|
const unreadCount = StoresModule.useStateFromStores([UnreadStore], () => {
|
||||||
if ((e.muted && !settings.misc.mutedChannels) || !settings.misc.channels) return 0;
|
if ((e.muted && !settings.misc.mutedChannels) || !settings.misc.channels) return 0;
|
||||||
|
@ -334,30 +331,13 @@ module.exports = (() => {
|
||||||
BadgesModule.NumberBadge({ count: unreadCount, color: e.muted ? ColorConverter.darkenColor(settings.misc.backgroundColor, settings.misc.mutedChannelBadgeDarkness * 100) : settings.misc.backgroundColor, style: { color: e.muted ? ColorConverter.darkenColor(settings.misc.textColor, settings.misc.mutedChannelBadgeDarkness * 100) : settings.misc.textColor } })
|
BadgesModule.NumberBadge({ count: unreadCount, color: e.muted ? ColorConverter.darkenColor(settings.misc.backgroundColor, settings.misc.mutedChannelBadgeDarkness * 100) : settings.misc.backgroundColor, style: { color: e.muted ? ColorConverter.darkenColor(settings.misc.textColor, settings.misc.mutedChannelBadgeDarkness * 100) : settings.misc.textColor } })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Patcher.after(ChannelItem.component.prototype, 'renderIcons', (_this, args, ret) => {
|
Patcher.after(TextChannel.component.prototype, 'render', (_this, _, ret) => {
|
||||||
|
const props = Utilities.findInReactTree(ret, e => e && Array.isArray(e.children) && e.children.find(e => e && e.type && e.type.displayName === 'ConnectedEditButton'));
|
||||||
|
if (!props || !props.children) return;
|
||||||
const badge = React.createElement(UnreadBadge, { channelId: _this.props.channel.id, muted: _this.props.muted && !_this.props.selected });
|
const badge = React.createElement(UnreadBadge, { channelId: _this.props.channel.id, muted: _this.props.muted && !_this.props.selected });
|
||||||
if (!ret) {
|
props.children.splice(this.settings.misc.channelsDisplayOnLeft ? 0 : 2, 0, badge);
|
||||||
return React.createElement(
|
|
||||||
'div',
|
|
||||||
{
|
|
||||||
onClick: e => e.stopPropagation(),
|
|
||||||
className: IconsChildren
|
|
||||||
},
|
|
||||||
badge
|
|
||||||
);
|
|
||||||
}
|
|
||||||
/* children is a refernce to the children prop within the component, which is bad
|
|
||||||
so appending it without slicing first would append it to the components props
|
|
||||||
children array
|
|
||||||
*/
|
|
||||||
const props = Utilities.findInReactTree(ret, e => Array.isArray(e.children) && e.children.find(e => e && e.type && e.type.displayName === 'ConnectedEditButton'));
|
|
||||||
if (!props) return;
|
|
||||||
const buttons = props.children.slice(0);
|
|
||||||
if (!buttons) return;
|
|
||||||
buttons.splice(this.settings.misc.channelsDisplayOnLeft ? 0 : 2, 0, badge);
|
|
||||||
props.children = buttons;
|
|
||||||
});
|
});
|
||||||
ChannelItem.forceUpdateAll();
|
TextChannel.forceUpdateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
async patchGuildFolder(promiseState) {
|
async patchGuildFolder(promiseState) {
|
||||||
|
@ -594,7 +574,7 @@ module.exports = (() => {
|
||||||
n = (n, e) => n && n._config && n._config.info && n._config.info.version && i(n._config.info.version, e),
|
n = (n, e) => n && n._config && n._config.info && n._config.info.version && i(n._config.info.version, e),
|
||||||
e = BdApi.getPlugin('ZeresPluginLibrary'),
|
e = BdApi.getPlugin('ZeresPluginLibrary'),
|
||||||
o = BdApi.getPlugin('XenoLib');
|
o = BdApi.getPlugin('XenoLib');
|
||||||
n(e, '1.2.23') && (ZeresPluginLibraryOutdated = !0), n(o, '1.3.26') && (XenoLibOutdated = !0);
|
n(e, '1.2.14') && (ZeresPluginLibraryOutdated = !0), n(o, '1.3.17') && (XenoLibOutdated = !0);
|
||||||
}
|
}
|
||||||
} catch (i) {
|
} catch (i) {
|
||||||
console.error('Error checking if libraries are out of date', i);
|
console.error('Error checking if libraries are out of date', i);
|
||||||
|
@ -618,7 +598,6 @@ module.exports = (() => {
|
||||||
getDescription() {
|
getDescription() {
|
||||||
return this.description + ' You are missing libraries for this plugin, please enable the plugin and click Download Now.';
|
return this.description + ' You are missing libraries for this plugin, please enable the plugin and click Download Now.';
|
||||||
}
|
}
|
||||||
start() {}
|
|
||||||
stop() { }
|
stop() { }
|
||||||
handleMissingLib() {
|
handleMissingLib() {
|
||||||
const a = BdApi.findModuleByProps('openModal', 'hasModalOpen');
|
const a = BdApi.findModuleByProps('openModal', 'hasModalOpen');
|
||||||
|
|
Loading…
Reference in New Issue