From d2f5e11fc741ee6315e7ddfc74729149526f441c Mon Sep 17 00:00:00 2001 From: Mikael Kristiansson Date: Mon, 12 Dec 2022 12:11:37 +0100 Subject: [PATCH] fix: timestamp will update when fetching new data (#17) --- CHANGELOG.md | 5 ++ package.json | 12 ++- src-tauri/Cargo.lock | 49 +++++------ src-tauri/Cargo.toml | 2 +- src-tauri/src/auto_start.rs | 156 ++++++++++++++++------------------ src-tauri/tauri.conf.json | 8 +- src/components/Reviews.svelte | 13 ++- 7 files changed, 130 insertions(+), 115 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bbe41a..5139f8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.4.2 + +# Fix +* update timestamp every time new fetch is called + ## 0.4.1 ### Fix diff --git a/package.json b/package.json index 03ca54d..18c810a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gitbar", "private": true, - "version": "0.4.1", + "version": "0.4.2", "type": "module", "scripts": { "dev": "vite", @@ -27,5 +27,13 @@ "tslib": "^2.4.1", "typescript": "^4.8.2", "vite": "^3.0.9" + }, + "prettier": { + "tabWidth": 4, + "trailingComma": "es5", + "semi": true, + "singleQuote": true, + "printWidth": 120, + "arrowParens": "avoid" } -} +} \ No newline at end of file diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 7f56b5f..5dbf377 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1268,9 +1268,9 @@ dependencies = [ [[package]] name = "json-patch" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f995a3c8f2bc3dd52a18a583e90f9ec109c047fa1603a853e46bcda14d2e279d" +checksum = "eb3fa5a61630976fc4c353c70297f2e93f1930e3ccee574d59d618ccbd5154ce" dependencies = [ "serde", "serde_json", @@ -1321,9 +1321,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.137" +version = "0.2.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" [[package]] name = "libdbus-sys" @@ -1528,9 +1528,9 @@ checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" [[package]] name = "notify-rust" -version = "4.5.10" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368e89ea58df747ce88be669ae44e79783c1d30bfd540ad0fc520b3f41f0b3b0" +checksum = "5cc2e370356160e41aba3fd0fbac26d86a89ddd2ac4300c03de999a77cfa2509" dependencies = [ "dbus", "mac-notification-sys", @@ -1665,9 +1665,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.43" +version = "0.10.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376" +checksum = "29d971fd5722fec23977260f6e81aa67d2f22cadbdc2aa049f1022d9a3be1566" dependencies = [ "bitflags", "cfg-if", @@ -1697,9 +1697,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.78" +version = "0.9.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132" +checksum = "5454462c0eced1e97f2ec09036abc8da362e66802f66fd20f86854d9d8cbcbc4" dependencies = [ "autocfg", "cc", @@ -1782,9 +1782,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f400b0f7905bf702f9f3dc3df5a121b16c54e9e8012c082905fdf09a931861a" +checksum = "cc8bed3549e0f9b0a2a78bf7c0018237a2cdf085eecbbc048e52612438e4e9d0" dependencies = [ "thiserror", "ucd-trie", @@ -2320,18 +2320,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.148" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" +checksum = "256b9932320c590e707b94576e3cc1f7c9024d0ee6612dfbcf1cb106cbe8e055" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.148" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" +checksum = "b4eae9b04cbffdfd550eb462ed33bc6a1b68c935127d008b27444d08380f94e4" dependencies = [ "proc-macro2", "quote", @@ -2565,9 +2565,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" dependencies = [ "proc-macro2", "quote", @@ -2950,15 +2950,16 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.22.0" +version = "1.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" +checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" dependencies = [ "autocfg", "bytes", "memchr", "num_cpus", "pin-project-lite", + "windows-sys 0.42.0", ] [[package]] @@ -3043,9 +3044,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" @@ -3640,9 +3641,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b4906cc7b3c5959893f3984bb60882ec94539eb14622077e6529f5b3d008ee" +checksum = "f20dd05f35fa0f8d107a4596b50d4e813b2e4f48cdec1f39854f092f7bbacc99" dependencies = [ "base64", "block", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index ed57c0e..fa5a004 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitbar" -version = "0.4.1" +version = "0.4.2" description = "Github review counter" authors = ["mikael.kristiansson"] license = "MIT" diff --git a/src-tauri/src/auto_start.rs b/src-tauri/src/auto_start.rs index 874c020..16293e9 100644 --- a/src-tauri/src/auto_start.rs +++ b/src-tauri/src/auto_start.rs @@ -1,9 +1,9 @@ use auto_launch::{AutoLaunch, AutoLaunchBuilder}; use serde::{ser::Serializer, Serialize}; use tauri::{ - command, - plugin::{Builder, TauriPlugin}, - Manager, Runtime, State, + command, + plugin::{Builder, TauriPlugin}, + Manager, Runtime, State, }; use std::env::current_exe; @@ -12,113 +12,107 @@ type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum Error { - #[error(transparent)] - Io(#[from] std::io::Error), - #[error("{0}")] - Anyhow(String), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error("{0}")] + Anyhow(String), } impl Serialize for Error { - fn serialize(&self, serializer: S) -> std::result::Result - where - S: Serializer, - { - serializer.serialize_str(self.to_string().as_ref()) - } + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } } pub struct AutoLaunchManager(AutoLaunch); impl AutoLaunchManager { - pub fn enable(&self) -> Result<()> { - self - .0 - .enable() - .map_err(|e| e.to_string()) - .map_err(Error::Anyhow) - } - - pub fn disable(&self) -> Result<()> { - self - .0 - .disable() - .map_err(|e| e.to_string()) - .map_err(Error::Anyhow) - } - - pub fn is_enabled(&self) -> Result { - self - .0 - .is_enabled() - .map_err(|e| e.to_string()) - .map_err(Error::Anyhow) - } + pub fn enable(&self) -> Result<()> { + self.0 + .enable() + .map_err(|e| e.to_string()) + .map_err(Error::Anyhow) + } + + pub fn disable(&self) -> Result<()> { + self.0 + .disable() + .map_err(|e| e.to_string()) + .map_err(Error::Anyhow) + } + + pub fn is_enabled(&self) -> Result { + self.0 + .is_enabled() + .map_err(|e| e.to_string()) + .map_err(Error::Anyhow) + } } pub trait ManagerExt { - fn autolaunch(&self) -> State<'_, AutoLaunchManager>; + fn autolaunch(&self) -> State<'_, AutoLaunchManager>; } impl> ManagerExt for T { - fn autolaunch(&self) -> State<'_, AutoLaunchManager> { - self.state::() - } + fn autolaunch(&self) -> State<'_, AutoLaunchManager> { + self.state::() + } } #[command] async fn enable(manager: State<'_, AutoLaunchManager>) -> Result<()> { - manager.enable() + manager.enable() } #[command] async fn disable(manager: State<'_, AutoLaunchManager>) -> Result<()> { - manager.disable() + manager.disable() } #[command] async fn is_enabled(manager: State<'_, AutoLaunchManager>) -> Result { - manager.is_enabled() + manager.is_enabled() } /// Initializes the plugin. /// /// `args` - are passed to your app on startup. -pub fn init( - args: Option>, -) -> TauriPlugin { - Builder::new("autostart") - .invoke_handler(tauri::generate_handler![enable, disable, is_enabled]) - .setup(move |app| { - let mut builder = AutoLaunchBuilder::new(); - let app_name = &app.package_info().name; - builder.set_app_name(app_name); - if let Some(args) = args { - builder.set_args(&args); - } - - - let current_exe = current_exe()?; - - #[cfg(windows)] - builder.set_app_path(¤t_exe.display().to_string()); - #[cfg(target_os = "macos")] - builder.set_use_launch_agent(true); - builder.set_app_path(¤t_exe.canonicalize()?.display().to_string()); - #[cfg(target_os = "linux")] - if let Some(appimage) = app - .env() - .appimage - .and_then(|p| p.to_str().map(|s| s.to_string())) - { - builder.set_app_path(&appimage); - } else { - builder.set_app_path(¤t_exe.display().to_string()); - } - - app.manage(AutoLaunchManager( - builder.build().map_err(|e| e.to_string())?, - )); - Ok(()) - }) - .build() +pub fn init(args: Option>) -> TauriPlugin { + Builder::new("autostart") + .invoke_handler(tauri::generate_handler![enable, disable, is_enabled]) + .setup(move |app| { + let mut builder = AutoLaunchBuilder::new(); + let app_name = &app.package_info().name; + builder.set_app_name(app_name); + if let Some(args) = args { + builder.set_args(&args); + } + + let current_exe = current_exe()?; + + #[cfg(windows)] + builder.set_app_path(¤t_exe.display().to_string()); + #[cfg(target_os = "macos")] + builder.set_use_launch_agent(true); + builder.set_app_path(¤t_exe.canonicalize()?.display().to_string()); + #[cfg(target_os = "linux")] + if let Some(appimage) = app + .env() + .appimage + .and_then(|p| p.to_str().map(|s| s.to_string())) + { + builder.set_app_path(&appimage); + } else { + builder.set_app_path(¤t_exe.display().to_string()); + } + + app.manage(AutoLaunchManager( + builder.build().map_err(|e| e.to_string())?, + )); + Ok(()) + }) + .build() } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index ee5a9fc..3987885 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,13 +8,15 @@ }, "package": { "productName": "GitBar", - "version": "0.4.1" + "version": "0.4.2" }, "tauri": { "allowlist": { "http": { "request": true, - "scope": ["https://**"] + "scope": [ + "https://**" + ] }, "notification": { "all": true @@ -81,4 +83,4 @@ } ] } -} +} \ No newline at end of file diff --git a/src/components/Reviews.svelte b/src/components/Reviews.svelte index 0052977..7f488fb 100644 --- a/src/components/Reviews.svelte +++ b/src/components/Reviews.svelte @@ -6,12 +6,14 @@ import { auth, defaultSettings } from '../lib/auth'; let loading = true; + let dateUpdater = 0; function onClick(url: string) { open(url); } const interval = setInterval(() => { $github.fetchReviews($auth.account); + dateUpdater++; }, $auth.settings.fetchInterval || defaultSettings.fetchInterval); onMount(() => { @@ -138,10 +140,13 @@ {review.node.title}
- - #{review.node.number} opened - {timeAgo(review.node.createdAt)} by @{review.node.author.login} - + {#key dateUpdater} + + #{review.node.number} opened + {timeAgo(review.node.createdAt)} by @{review.node.author + .login} + + {/key}