Skip to content

Commit

Permalink
fix: notification call before store update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Kristiansson committed Dec 1, 2022
1 parent d22373d commit fbbec97
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.4.1

### Fix
* change order when calling notification (before store update)

## 0.4.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gitbar",
"private": true,
"version": "0.4.0",
"version": "0.4.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gitbar"
version = "0.4.0"
version = "0.4.1"
description = "Github review counter"
authors = ["mikael.kristiansson"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "GitBar",
"version": "0.4.0"
"version": "0.4.1"
},
"tauri": {
"allowlist": {
Expand Down
12 changes: 6 additions & 6 deletions src/lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ const fetchReviews = async (account: AuthState) => {
const res = await getReviews(account);
let prevCount: number;
github.subscribe(({ reviews }) => (prevCount = reviews.count));

if (res.issueCount > prevCount) {
const title = res.edges[0].node.title;
const author = res.edges[0].node.author.login;
notification(`${title} - @${author}`);
}
if (res.issueCount !== prevCount) {
github.update((prev) => ({
...prev,
Expand All @@ -41,12 +47,6 @@ const fetchReviews = async (account: AuthState) => {
}));
invoke('set_review_count', { count: String(res.issueCount) });
}

if (res.issueCount > prevCount) {
const title = res.edges[0].node.title;
const author = res.edges[0].node.author.login;
notification(`${title} - @${author}`);
}
};

export const github = writable({
Expand Down

0 comments on commit fbbec97

Please sign in to comment.