Skip to content

Commit fc5f5a9

Browse files
committed
Discord Activity: Filter out custom activities
1 parent 46b9c0c commit fc5f5a9

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/common/useDiscordActivityTracker.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,23 @@ export const useDiscordActivityTracker = () => {
8484
setStorageString(StorageKeys.DISCORD_USER_ID, "");
8585
return;
8686
}
87-
const activity = (data.activities as FormattedActivity[]).sort((a, b) => {
88-
const isASpotify = !!a.assets?.largeImage?.startsWith("spotify:");
89-
const isBSpotify = !!b.assets?.largeImage?.startsWith("spotify:");
87+
const activity = (data.activities as FormattedActivity[])
88+
.filter((a) => a.type !== ActivityType.CUSTOM)
89+
.sort((a, b) => {
90+
const isASpotify = !!a.assets?.largeImage?.startsWith("spotify:");
91+
const isBSpotify = !!b.assets?.largeImage?.startsWith("spotify:");
9092

91-
// Ensure Spotify activities are placed at the end of the list
92-
if (isASpotify && !isBSpotify) {
93-
return 1; // a comes after b
94-
}
95-
if (!isASpotify && isBSpotify) {
96-
return -1; // a comes before b
97-
}
93+
// Ensure Spotify activities are placed at the end of the list
94+
if (isASpotify && !isBSpotify) {
95+
return 1; // a comes after b
96+
}
97+
if (!isASpotify && isBSpotify) {
98+
return -1; // a comes before b
99+
}
98100

99-
// If neither or both are Spotify, maintain the original order (or add another sorting criteria)
100-
return 0;
101-
})[0];
101+
// If neither or both are Spotify, maintain the original order (or add another sorting criteria)
102+
return 0;
103+
})[0];
102104
if (!activity) {
103105
localRPC.updateRPC(NERIMITY_APP_ID);
104106
return;

0 commit comments

Comments
 (0)