diff --git a/src/plugins/ignoreActivities/index.tsx b/src/plugins/ignoreActivities/index.tsx index 02261b5ba..8c36e1d75 100644 --- a/src/plugins/ignoreActivities/index.tsx +++ b/src/plugins/ignoreActivities/index.tsx @@ -266,7 +266,7 @@ export default definePlugin({ replace: (m, props, nowPlaying) => `${m}$self.renderToggleGameActivityButton(${props},${nowPlaying}),` } }, - // Discord has 3 different components for activities. Currently, the last is the one being used + // Discord has 2 different components for activities. Currently, the last is the one being used { find: ".activityTitleText,variant", replacement: { @@ -274,13 +274,6 @@ export default definePlugin({ replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` }, }, - { - find: ".activityCardDetails,children", - replacement: { - match: /\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),/, - replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),` - } - }, { find: ".promotedLabelWrapperNonBanner,children", replacement: { diff --git a/src/plugins/noPendingCount/index.ts b/src/plugins/noPendingCount/index.ts index 0995621fa..d3e27563b 100644 --- a/src/plugins/noPendingCount/index.ts +++ b/src/plugins/noPendingCount/index.ts @@ -62,16 +62,7 @@ export default definePlugin({ replace: "return 0;" } }, - // New message requests hook - { - find: 'location:"use-message-requests-count"', - predicate: () => settings.store.hideMessageRequestsCount, - replacement: { - match: /getNonChannelAckId\(\i\.\i\.MESSAGE_REQUESTS\).+?return /, - replace: "$&0;" - } - }, - // Old message requests hook + // Message requests hook { find: "getMessageRequestsCount(){", predicate: () => settings.store.hideMessageRequestsCount, diff --git a/src/plugins/timeBarAllActivities/index.tsx b/src/plugins/timeBarAllActivities/index.tsx index 91b1bc2f1..660d20bbf 100644 --- a/src/plugins/timeBarAllActivities/index.tsx +++ b/src/plugins/timeBarAllActivities/index.tsx @@ -5,9 +5,11 @@ */ import { definePluginSettings } from "@api/Settings"; +import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; +import { RequiredDeep } from "type-fest"; interface Activity { timestamps?: ActivityTimestamps; @@ -18,7 +20,15 @@ interface ActivityTimestamps { end?: string; } -const ActivityTimeBar = findComponentByCodeLazy(".Millis.HALF_SECOND", ".bar", ".progress"); +interface TimebarComponentProps { + activity: Activity; +} + +const ActivityTimeBar = findComponentByCodeLazy(".bar", ".progress", "(100*"); + +function isActivityTimestamped(activity: Activity): activity is RequiredDeep { + return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null; +} export const settings = definePluginSettings({ hideActivityDetailText: { @@ -45,7 +55,7 @@ export default definePlugin({ // Insert Spotify time bar component { match: /\(0,.{0,30}activity:(\i),className:\i\.badges\}\)/g, - replace: "$&,$self.getTimeBar($1)" + replace: "$&,$self.TimebarComponent({activity:$1})" }, // Hide the large title on listening activities, to make them look more like Spotify (also visible from hovering over the large icon) { @@ -64,13 +74,11 @@ export default definePlugin({ } ], - isActivityTimestamped(activity: Activity) { - return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null; - }, + isActivityTimestamped, - getTimeBar(activity: Activity) { - if (this.isActivityTimestamped(activity)) { - return ; - } - } + TimebarComponent: ErrorBoundary.wrap(({ activity }: TimebarComponentProps) => { + if (!isActivityTimestamped(activity)) return null; + + return ; + }, { noop: true }) });