mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-17 02:17:03 -04:00
feat: auto-managed flux subscriptions via plugin.flux (#959)
This commit is contained in:
parent
c6f0c84935
commit
63fc354d48
10 changed files with 210 additions and 253 deletions
|
@ -18,12 +18,10 @@
|
|||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { FluxDispatcher } from "@webpack/common";
|
||||
|
||||
import { forEachEvent } from "./events";
|
||||
import { removeFriend, removeGroup, removeGuild } from "./functions";
|
||||
import { onChannelDelete, onGuildDelete, onRelationshipRemove, removeFriend, removeGroup, removeGuild } from "./functions";
|
||||
import settings from "./settings";
|
||||
import { syncAndRunChecks } from "./utils";
|
||||
import { syncAndRunChecks, syncFriends, syncGroups, syncGuilds } from "./utils";
|
||||
|
||||
export default definePlugin({
|
||||
name: "RelationshipNotifier",
|
||||
|
@ -55,15 +53,24 @@ export default definePlugin({
|
|||
}
|
||||
],
|
||||
|
||||
flux: {
|
||||
GUILD_CREATE: syncGuilds,
|
||||
GUILD_DELETE: onGuildDelete,
|
||||
CHANNEL_CREATE: syncGroups,
|
||||
CHANNEL_DELETE: onChannelDelete,
|
||||
RELATIONSHIP_ADD: syncFriends,
|
||||
RELATIONSHIP_UPDATE: syncFriends,
|
||||
RELATIONSHIP_REMOVE(e) {
|
||||
onRelationshipRemove(e);
|
||||
syncFriends();
|
||||
},
|
||||
CONNECTION_OPEN: syncAndRunChecks
|
||||
},
|
||||
|
||||
async start() {
|
||||
setTimeout(() => {
|
||||
syncAndRunChecks();
|
||||
}, 5000);
|
||||
forEachEvent((ev, cb) => FluxDispatcher.subscribe(ev, cb));
|
||||
},
|
||||
|
||||
stop() {
|
||||
forEachEvent((ev, cb) => FluxDispatcher.unsubscribe(ev, cb));
|
||||
},
|
||||
|
||||
removeFriend,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue