Skip to content

Commit 72c771b

Browse files
committed
feat(filter): avoid further enrichment if state not visible
Signed-off-by: Adam Setch <[email protected]>
1 parent 061e720 commit 72c771b

File tree

4 files changed

+243
-74
lines changed

4 files changed

+243
-74
lines changed

src/renderer/utils/notifications/filters/filter.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,8 @@ export function filterDetailedNotifications(
6969
);
7070
}
7171

72-
if (stateFilter.hasFilters(settings)) {
73-
passesFilters =
74-
passesFilters &&
75-
settings.filterStates.some((state) =>
76-
stateFilter.filterNotification(notification, state),
77-
);
78-
}
72+
passesFilters =
73+
passesFilters && isNotificationStateVisible(notification, settings);
7974
}
8075

8176
return passesFilters;
@@ -92,3 +87,16 @@ export function hasAnyFiltersSet(settings: SettingsState): boolean {
9287
reasonFilter.hasFilters(settings)
9388
);
9489
}
90+
91+
export function isNotificationStateVisible(
92+
notification: Notification,
93+
settings: SettingsState,
94+
): boolean {
95+
if (stateFilter.hasFilters(settings)) {
96+
return settings.filterStates.some((state) =>
97+
stateFilter.filterNotification(notification, state),
98+
);
99+
}
100+
101+
return true;
102+
}

src/renderer/utils/notifications/notifications.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ export async function enrichNotifications(
108108
let additionalSubjectDetails: GitifySubject = {};
109109

110110
try {
111-
additionalSubjectDetails = await getGitifySubjectDetails(notification);
111+
additionalSubjectDetails = await getGitifySubjectDetails(
112+
notification,
113+
settings,
114+
);
112115
} catch (err) {
113116
logError(
114117
'enrichNotifications',

0 commit comments

Comments
 (0)