Skip to content

Commit 6e042a3

Browse files
authored
Merge pull request #36 from jamiefdhurst/fix-multiple-notices
fix: stop notice from displaying twice
2 parents 85a6da0 + 9fcd8c7 commit 6e042a3

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/__tests__/notice.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,15 @@ describe('OrganiserNotice', () => {
181181

182182
expect(inboxGetFiles).not.toHaveBeenCalled();
183183
});
184+
185+
it('does nothing for Fri 5pm when just beyond five minute window', () => {
186+
const inboxGetFiles = jest.spyOn(inbox, 'getFiles').mockReturnValue([]);
187+
settings.inbox = true;
188+
settings.period = 'weekly_fri_5pm';
189+
now.set({ date: 3, month: 0, year: 2025, hour: 17, minute: 5, second: 0 });
190+
191+
sut.display();
192+
193+
expect(inboxGetFiles).not.toHaveBeenCalled();
194+
});
184195
});

src/notice.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class OrganiserNotice {
3939
settings.period === 'daily_9am' &&
4040
!this.now.isBetween(
4141
this.now.clone().set({ hour: 9, minute: 0, second: 0 }),
42-
this.now.clone().set({ hour: 9, minute: 9, second: 59 })
42+
this.now.clone().set({ hour: 9, minute: 4, second: 59 })
4343
)
4444
) {
4545
return;
@@ -48,7 +48,7 @@ export class OrganiserNotice {
4848
settings.period === 'daily_11am' &&
4949
!this.now.isBetween(
5050
this.now.clone().set({ hour: 11, minute: 0, second: 0 }),
51-
this.now.clone().set({ hour: 11, minute: 9, second: 59 })
51+
this.now.clone().set({ hour: 11, minute: 4, second: 59 })
5252
)
5353
) {
5454
return;
@@ -57,7 +57,7 @@ export class OrganiserNotice {
5757
settings.period === 'daily_3pm' &&
5858
!this.now.isBetween(
5959
this.now.clone().set({ hour: 15, minute: 0, second: 0 }),
60-
this.now.clone().set({ hour: 15, minute: 9, second: 59 })
60+
this.now.clone().set({ hour: 15, minute: 4, second: 59 })
6161
)
6262
) {
6363
return;
@@ -66,7 +66,7 @@ export class OrganiserNotice {
6666
settings.period === 'daily_5pm' &&
6767
!this.now.isBetween(
6868
this.now.clone().set({ hour: 17, minute: 0, second: 0 }),
69-
this.now.clone().set({ hour: 17, minute: 9, second: 59 })
69+
this.now.clone().set({ hour: 17, minute: 4, second: 59 })
7070
)
7171
) {
7272
return;
@@ -76,7 +76,7 @@ export class OrganiserNotice {
7676
(this.now.format('dd') !== 'Mo' ||
7777
!this.now.isBetween(
7878
this.now.clone().set({ hour: 9, minute: 0, second: 0 }),
79-
this.now.clone().set({ hour: 9, minute: 9, second: 59 })
79+
this.now.clone().set({ hour: 9, minute: 4, second: 59 })
8080
))
8181
) {
8282
return;
@@ -86,7 +86,7 @@ export class OrganiserNotice {
8686
(this.now.format('dd') !== 'Mo' ||
8787
!this.now.isBetween(
8888
this.now.clone().set({ hour: 17, minute: 0, second: 0 }),
89-
this.now.clone().set({ hour: 17, minute: 9, second: 59 })
89+
this.now.clone().set({ hour: 17, minute: 4, second: 59 })
9090
))
9191
) {
9292
return;
@@ -96,7 +96,7 @@ export class OrganiserNotice {
9696
(this.now.format('dd') !== 'Fr' ||
9797
!this.now.isBetween(
9898
this.now.clone().set({ hour: 9, minute: 0, second: 0 }),
99-
this.now.clone().set({ hour: 9, minute: 9, second: 59 })
99+
this.now.clone().set({ hour: 9, minute: 4, second: 59 })
100100
))
101101
) {
102102
return;
@@ -106,7 +106,7 @@ export class OrganiserNotice {
106106
(this.now.format('dd') !== 'Fr' ||
107107
!this.now.isBetween(
108108
this.now.clone().set({ hour: 17, minute: 0, second: 0 }),
109-
this.now.clone().set({ hour: 17, minute: 9, second: 59 })
109+
this.now.clone().set({ hour: 17, minute: 4, second: 59 })
110110
))
111111
) {
112112
return;

0 commit comments

Comments
 (0)