Skip to content

Commit

Permalink
fix(gitlab): ignore updated event (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlienard authored May 13, 2024
1 parent de47406 commit 5bd275a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
8 changes: 2 additions & 6 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
"custom-property-empty-line-before": "never",
"no-descending-specificity": null,
"property-no-vendor-prefix": null,
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": ["global"]
}
]
"selector-pseudo-class-no-unknown": [true, { "ignorePseudoClasses": ["global"] }],
"scss/no-global-function-names": null
}
}
27 changes: 16 additions & 11 deletions src/lib/features/createGitlabNotificationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,21 @@ export async function prepareGitlabNotificationData(events: GitlabEventWithRepoD
) {
type = 'Issue';
}
const data = await fetchGitlab<GitlabMergeRequest | GitlabIssue>(
`projects/${firstEvent.repository.encoded}/${
type === 'Issue' ? 'issues' : 'merge_requests'
}/${isNote ? firstEvent.note.noteable_iid : firstEvent.target_iid}`
);
return {
target_id: item.target_id,
ref: item.ref,
events: item.events,
data
};
try {
const data = await fetchGitlab<GitlabMergeRequest | GitlabIssue>(
`projects/${firstEvent.repository.encoded}/${
type === 'Issue' ? 'issues' : 'merge_requests'
}/${isNote ? firstEvent.note.noteable_iid : firstEvent.target_iid}`
);
return {
target_id: item.target_id,
ref: item.ref,
events: item.events,
data
};
} catch {
return item;
}
} else {
return item;
}
Expand Down Expand Up @@ -262,6 +266,7 @@ export async function createGitlabNotificationData(
case 'created':
case 'deleted':
case 'joined':
case 'updated':
return null;

default:
Expand Down
6 changes: 6 additions & 0 deletions src/lib/types/gitlab-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export type GitlabEvent = {
target_iid: number;
target_type: null;
}
| {
action_name: 'updated';
target_id: number;
target_iid: number;
target_type: null;
}
| {
action_name: 'approved';
target_id: number;
Expand Down
7 changes: 6 additions & 1 deletion src/routes/(app)/dashboard/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@
let newNotifications: NotificationData[] = [];
const savedNotifications = storage.get('gitlab-notifications') || [];
const ignoredNotificationTypes: GitlabEvent['action_name'][] = ['created', 'deleted', 'joined'];
const ignoredNotificationTypes: GitlabEvent['action_name'][] = [
'created',
'deleted',
'joined',
'updated'
];
const persons = storage.get('watched-persons') || [];
const repos = storage.get('watched-repos') || [];
const firstFetch = !$gitlabNotifications.length;
Expand Down

0 comments on commit 5bd275a

Please sign in to comment.