Update FriendNotifications.plugin.js

This commit is contained in:
Mirco Wittrien 2021-08-02 21:07:53 +02:00
parent 9be0fd12c7
commit 25bda92120
1 changed files with 9 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* @name FriendNotifications * @name FriendNotifications
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.7.5 * @version 1.7.6
* @description Shows a Notification when a Friend or a User, you choose to observe, changes their Status * @description Shows a Notification when a Friend or a User, you choose to observe, changes their Status
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,15 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "FriendNotifications", "name": "FriendNotifications",
"author": "DevilBro", "author": "DevilBro",
"version": "1.7.5", "version": "1.7.6",
"description": "Shows a Notification when a Friend or a User, you choose to observe, changes their Status" "description": "Shows a Notification when a Friend or a User, you choose to observe, changes their Status"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"$statusOld $status": "Both work now" "Crash": ""
},
"improved": {
"Default Settings": "Added extended Options to configure a default Setup for new Users"
} }
} }
}; };
@ -753,7 +750,7 @@ module.exports = (_ => {
injectCounter (returnvalue) { injectCounter (returnvalue) {
let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {name: "ConnectedUnreadDMs"}); let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {name: "ConnectedUnreadDMs"});
if (index > -1) children.splice(index, 0, BDFDB.ReactUtils.createElement(FriendOnlineCounterComponent, { if (index > -1) children.splice(index, 0, BDFDB.ReactUtils.createElement(FriendOnlineCounterComponent, {
amount: BDFDB.LibraryModules.StatusMetaUtils.getOnlineFriendCount() amount: this.getOnlineCount()
})); }));
} }
@ -812,6 +809,10 @@ module.exports = (_ => {
activityIsSame (id, status) { activityIsSame (id, status) {
return BDFDB.equals(BDFDB.ObjectUtils.extract(userStatusStore[id].activity, "name", "details", "state", "emoji"), status && BDFDB.ObjectUtils.extract(status.activity, "name", "details", "state", "emoji")); return BDFDB.equals(BDFDB.ObjectUtils.extract(userStatusStore[id].activity, "name", "details", "state", "emoji"), status && BDFDB.ObjectUtils.extract(status.activity, "name", "details", "state", "emoji"));
} }
getOnlineCount () {
return Object.entries(BDFDB.LibraryModules.RelationshipStore.getRelationships()).filter(n => n[1] == BDFDB.DiscordConstants.RelationshipTypes.FRIEND && BDFDB.LibraryModules.StatusMetaUtils.getStatus(n[0]) != BDFDB.DiscordConstants.StatusTypes.OFFLINE).length;
}
startInterval () { startInterval () {
BDFDB.TimeUtils.clear(checkInterval); BDFDB.TimeUtils.clear(checkInterval);
@ -824,7 +825,7 @@ module.exports = (_ => {
for (let id in observedUsers) userStatusStore[id] = this.getStatusWithMobileAndActivity(id, observedUsers[id], clientStatuses); for (let id in observedUsers) userStatusStore[id] = this.getStatusWithMobileAndActivity(id, observedUsers[id], clientStatuses);
checkInterval = BDFDB.TimeUtils.interval(_ => { checkInterval = BDFDB.TimeUtils.interval(_ => {
let amount = BDFDB.LibraryModules.StatusMetaUtils.getOnlineFriendCount(); let amount = this.getOnlineCount();
if (friendCounter && friendCounter.props.amount != amount) { if (friendCounter && friendCounter.props.amount != amount) {
friendCounter.props.amount = amount; friendCounter.props.amount = amount;
BDFDB.ReactUtils.forceUpdate(friendCounter); BDFDB.ReactUtils.forceUpdate(friendCounter);