Skip to content

Commit

Permalink
Add (paused) to shifty status bar when shift interval is paused
Browse files Browse the repository at this point in the history
  • Loading branch information
bmealhouse committed Jul 20, 2019
1 parent a8fb583 commit eed1852
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.1] - 2019-07-19

### Added

- Display "(paused)" in status bar when shift interval is paused

## [1.1.1] - 2019-07-14

### Added
Expand Down
10 changes: 7 additions & 3 deletions src/shift-interval/ipc-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,17 @@ export async function start({

if (shiftColorThemeIntervalEnabled && shiftFontFamilyIntervalEnabled) {
if (shiftColorThemeRemainingSeconds < shiftFontFamilyRemainingSeconds) {
return `${pad0(min)}:${pad0(sec)} (color theme)`;
return `${pad0(min)}:${pad0(sec)} (${
lastPauseTime > 0 ? 'paused' : 'color theme'
})`;
}

if (shiftFontFamilyRemainingSeconds < shiftColorThemeRemainingSeconds) {
min = Math.max(0, Math.floor(shiftFontFamilyRemainingSeconds / 60));
sec = Math.max(0, shiftFontFamilyRemainingSeconds % 60);
let calculationResult = `${pad0(min)}:${pad0(sec)} (font family)`;
let calculationResult = `${pad0(min)}:${pad0(sec)} (${
lastPauseTime > 0 ? 'paused' : 'font family'
})`;

if (
!hasDebuggedFontFamilyStatus &&
Expand All @@ -286,7 +290,7 @@ export async function start({
}
}

return `${pad0(min)}:${pad0(sec)}`;
return `${pad0(min)}:${pad0(sec)}${lastPauseTime > 0 ? ' (paused)' : ''}`;
}

ipc.server.start();
Expand Down
22 changes: 22 additions & 0 deletions src/test/shift-interval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,28 @@ suite('shift-interval.test.ts', () => {
await client.close();
});

test('should display remaining time "##:## (paused)" when the shift interval is paused', async () => {
const server = await ipcServer.start(connectionOptions);
const client = await ipcClient.connect(connectionOptions);

await sleep(25);

server.pauseShiftInterval();
await sleep(25);

assert.ok(
/^\d{2}:\d{2} \(paused\)$/.exec(
client.lastUpdateStatusMessageReceived.text,
),
`The regular expression evaluated to a falsy for "${
client.lastUpdateStatusMessageReceived.text
}"`,
);

await client.close();
server.close();
});

test('should display remaining time "##:##" when the font family shift interval has been disabled', async () => {
await setConfig('shifty.shiftInterval.shiftColorThemeIntervalMin', 10);
await setConfig('shifty.shiftInterval.shiftFontFamilyIntervalMin', null);
Expand Down

0 comments on commit eed1852

Please sign in to comment.