Skip to content

Commit ae377ab

Browse files
committed
refactor(api): use @octokit/types REST schema type
Signed-off-by: Adam Setch <[email protected]>
1 parent dfb90a2 commit ae377ab

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

src/renderer/utils/notifications/handlers/commit.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,27 @@ class CommitHandler extends DefaultHandler {
3939
)
4040
).data;
4141

42-
user = {
43-
login: commitComment.user.login,
44-
html_url: commitComment.user.html_url,
45-
avatar_url: commitComment.user.avatar_url,
46-
type: commitComment.user.type,
47-
};
42+
user = commitComment.user
43+
? {
44+
login: commitComment.user.login,
45+
html_url: commitComment.user.html_url,
46+
avatar_url: commitComment.user.avatar_url,
47+
type: commitComment.user.type,
48+
}
49+
: null;
4850
} else {
4951
const commit = (
5052
await getCommit(notification.subject.url, notification.account.token)
5153
).data;
5254

53-
user = {
54-
login: commit.author.login,
55-
html_url: commit.author.html_url,
56-
avatar_url: commit.author.avatar_url,
57-
type: commit.author.type,
58-
};
55+
user = commit.author
56+
? {
57+
login: commit.author.login,
58+
html_url: commit.author.html_url,
59+
avatar_url: commit.author.avatar_url,
60+
type: commit.author.type,
61+
}
62+
: null;
5963
}
6064

6165
return {

src/renderer/utils/notifications/handlers/release.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { TagIcon } from '@primer/octicons-react';
55

66
import type {
77
GitifyNotificationState,
8+
GitifyNotificationUser,
89
GitifySubject,
910
Link,
1011
SettingsState,
@@ -33,16 +34,18 @@ class ReleaseHandler extends DefaultHandler {
3334
await getRelease(notification.subject.url, notification.account.token)
3435
).data;
3536

36-
return {
37-
state: releaseState,
38-
user: getNotificationAuthor([
39-
{
37+
const releaseAuthor: GitifyNotificationUser = release.author
38+
? {
4039
login: release.author.login,
4140
html_url: release.author.html_url,
4241
avatar_url: release.author.avatar_url,
4342
type: release.author.type,
44-
},
45-
]),
43+
}
44+
: null;
45+
46+
return {
47+
state: releaseState,
48+
user: getNotificationAuthor([releaseAuthor]),
4649
};
4750
}
4851

0 commit comments

Comments
 (0)