Skip to content

Commit

Permalink
fix: streak notification message
Browse files Browse the repository at this point in the history
Fixed streak notification message to show the streak which is at risk of
being lost instead of the current streak (which is always 0 if at risk)
  • Loading branch information
jamieweavis committed Aug 29, 2023
1 parent dea2c9d commit ceec31e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

### Manual

Download the latest version of Streaker from the **[GitHub releases](https://github.com/jamieweavis/streaker/releases)** page. (currently macOS & Windows only, track work for Linux support in [#2](https://github.com/jamieweavis/streaker/issues/2))
Download the latest version of Streaker from the **[GitHub releases](https://github.com/jamieweavis/streaker/releases)** page. (currently macOS & Windows only, track Linux support in [#2](https://github.com/jamieweavis/streaker/issues/2))

### Homebrew Cask
### Homebrew

Coming soon™, track progress in [#138](https://github.com/jamieweavis/streaker/issues/138)

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dependencies": {
"@primer/components": "23.2.1",
"auto-launch": "5.0.5",
"contribution": "5.0.3",
"contribution": "5.2.0",
"cron": "1.8.2",
"electron-store": "7.0.3",
"formik": "2.2.9",
Expand Down
26 changes: 9 additions & 17 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,15 @@ const bootstrap = (): void => {

let stats: GitHubStats;
let icon = iconThemes[iconTheme].pending;

try {
stats = await fetchStats(username);
// For screenshots
// stats = {
// contributions: {
// best: 42,
// current: 13,
// total: 1337,
// },
// streak: {
// best: 69,
// current: 5,
// },
// };
if (stats?.streak?.current > 0) icon = iconThemes[iconTheme].contributed;
if (stats?.streak?.current === stats?.streak?.best)
if (stats.streak.current > 0) {
icon = iconThemes[iconTheme].contributed;
}
if (stats.streak.current === stats.streak.best) {
icon = iconThemes[iconTheme].streaking;
}
} catch (err) {
icon = iconThemes[iconTheme].error;
}
Expand Down Expand Up @@ -153,7 +145,7 @@ const bootstrap = (): void => {
});

// Platform specific app handling
app.on('window-all-closed', () => {}); // eslint-disable-line
app.on('window-all-closed', () => {});
if (process.platform === 'darwin') app.dock.hide();

// Save preferences to store on renderer preferences save
Expand All @@ -167,10 +159,10 @@ const triggerReminderNotification = async (): Promise<void> => {
if (!Notification.isSupported()) return;
const username = store.get('username');
const stats = await fetchStats(username);
if (stats?.contributions?.current === 0 && stats?.streak?.current > 0) {
if (stats.streak.isAtRisk) {
new Notification({
title: `🔥 Don't lose your streak!`,
body: `Contribute today to continue your ${stats.streak.current} day streak on GitHub`,
body: `Contribute today to continue your ${stats.streak.previous} day streak on GitHub`,
}).show();
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ export const createMenu = ({
},
{ type: 'separator' },
{ label: 'Streak:', enabled: false },
{ label: ` Best: ${stats?.streak?.best || 0}`, enabled: false },
{ label: ` Best: ${stats.streak.best}`, enabled: false },
{
label: ` Current: ${stats?.streak?.current || 0}`,
label: ` Current: ${stats.streak.current}`,
enabled: false,
},
{ label: 'Contributions:', enabled: false },
{
label: ` Best: ${stats?.contributions?.best || 0}`,
label: ` Best: ${stats.contributions.best}`,
enabled: false,
},
{
label: ` Current: ${stats?.contributions?.current || 0}`,
label: ` Current: ${stats.contributions.current}`,
enabled: false,
},
{
label: ` Total: ${stats?.contributions?.total || 0}`,
label: ` Total: ${stats.contributions.total}`,
enabled: false,
},
{ type: 'separator' },
Expand Down
4 changes: 0 additions & 4 deletions src/renderer/components/preferences-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const PreferencesForm = (): JSX.Element => (
fontWeight="bold"
fontSize="14px"
as="label"
// eslint-disable-next-line
// @ts-ignore
htmlFor="github-username"
style={{ display: 'block' }}
Expand Down Expand Up @@ -74,7 +73,6 @@ const PreferencesForm = (): JSX.Element => (
fontWeight="bold"
fontSize="14px"
as="label"
// eslint-disable-next-line
// @ts-ignore
htmlFor="launch-at-login"
style={{ display: 'block' }}
Expand All @@ -88,7 +86,6 @@ const PreferencesForm = (): JSX.Element => (
fontWeight="bold"
fontSize="14px"
as="label"
// eslint-disable-next-line
// @ts-ignore
htmlFor="notification-enabled"
style={{ display: 'block' }}
Expand All @@ -108,7 +105,6 @@ const PreferencesForm = (): JSX.Element => (
fontWeight="bold"
fontSize="14px"
as="label"
// eslint-disable-next-line
// @ts-ignore
htmlFor="reminder-time"
style={{ display: 'block' }}
Expand Down

0 comments on commit ceec31e

Please sign in to comment.