aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuckyz <61953774+Nuckyz@users.noreply.github.com>2022-10-26 10:31:55 -0300
committerGitHub <noreply@github.com>2022-10-26 15:31:55 +0200
commitbbd3633038adf30c9476ef6b95152a92ebb4823b (patch)
tree12797cb6e208f8265bea1d614e4b2ad14b9f24a8
parentc65f757bc450beee76c4266610a13f6f56ed7b94 (diff)
downloadVencord-bbd3633038adf30c9476ef6b95152a92ebb4823b.tar.gz
Vencord-bbd3633038adf30c9476ef6b95152a92ebb4823b.tar.bz2
Vencord-bbd3633038adf30c9476ef6b95152a92ebb4823b.zip
fix(Ignore Activities): Fixes games manually added not being able to be ignored (#162)
Co-authored-by: Ven <vendicated@riseup.net>
-rw-r--r--src/plugins/ignoreActivities.ts39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/plugins/ignoreActivities.ts b/src/plugins/ignoreActivities.ts
index cc1538a..dd4650b 100644
--- a/src/plugins/ignoreActivities.ts
+++ b/src/plugins/ignoreActivities.ts
@@ -28,7 +28,7 @@ interface MatchAndReplace {
}
/** Used to re-render the Registered Games tab to update how our button looks like */
-const RunningGameStore = lazyWebpack(filters.byProps(["IgnoreActivities_reRenderGames"]));
+const RunningGameStoreModule = lazyWebpack(filters.byProps(["IgnoreActivities_reRenderGames"]));
let ignoredActivitiesCache: string[] = [];
@@ -134,19 +134,44 @@ export default definePlugin({
async start() {
ignoredActivitiesCache = (await DataStore.get<string[]>("IgnoreActivities_ignoredActivities")) ?? [];
+
+ if (ignoredActivitiesCache.length !== 0) {
+ const gamesSeen: Record<string, any>[] = RunningGameStoreModule.Z.getGamesSeen();
+
+ for (const [index, ignoredActivity] of ignoredActivitiesCache.entries()) {
+ if (!gamesSeen.some(game => (game.id !== undefined && game.id === ignoredActivity) || game.exePath === ignoredActivity)) {
+ ignoredActivitiesCache.splice(index, 1);
+ }
+ }
+
+ await DataStore.set("IgnoreActivities_ignoredActivities", ignoredActivitiesCache);
+ }
},
- /** This method is used in different places. The Registered Games tab game props only have an id and the LocalActivityStore have the application_id */
isActivityEnabled(props: Record<string, any>) {
- if ("application_id" in props) return !ignoredActivitiesCache.includes(props.application_id);
- else if ("id" in props) return !ignoredActivitiesCache.includes(props.id);
+ /** LocalActivityStore games have a "type" prop */
+ if ("type" in props) {
+ if (props.application_id !== undefined) return !ignoredActivitiesCache.includes(props.application_id);
+ else {
+ const exePath = RunningGameStoreModule.Z.getRunningGames().find(game => game.name === props.name)?.exePath;
+ if (exePath) return !ignoredActivitiesCache.includes(exePath);
+ }
+ }
+ /** Registered Games tab games have an "id" prop */
+ else if ("id" in props) {
+ if (props.id !== undefined) return !ignoredActivitiesCache.includes(props.id);
+ else return !ignoredActivitiesCache.includes(props.exePath);
+ }
return true;
},
async handleActivityToggle(props: Record<string, any>) {
- if (ignoredActivitiesCache.includes(props.id)) ignoredActivitiesCache.splice(ignoredActivitiesCache.indexOf(props.id, 1));
- else ignoredActivitiesCache.push(props.id);
- RunningGameStore.IgnoreActivities_reRenderGames();
+ const id = props.id ?? props.exePath;
+ if (id === undefined) return;
+
+ if (ignoredActivitiesCache.includes(id)) ignoredActivitiesCache.splice(ignoredActivitiesCache.indexOf(id, 1));
+ else ignoredActivitiesCache.push(id);
+ RunningGameStoreModule.IgnoreActivities_reRenderGames();
await DataStore.set("IgnoreActivities_ignoredActivities", ignoredActivitiesCache);
}
});