From d22373db4735929d71ffdbb25c5676b294962e82 Mon Sep 17 00:00:00 2001 From: Mikael Kristiansson Date: Wed, 30 Nov 2022 14:02:57 +0100 Subject: [PATCH] fix: change date format and auto start (#12) --- CHANGELOG.md | 11 ++ package.json | 4 +- src-tauri/Cargo.lock | 205 ++++++++++++--------------------- src-tauri/Cargo.toml | 6 +- src-tauri/src/auto_start.rs | 12 +- src-tauri/src/main.rs | 2 - src-tauri/tauri.conf.json | 8 +- src/components/Footer.svelte | 17 ++- src/components/Modal.svelte | 4 - src/components/Reviews.svelte | 101 +++++++++------- src/components/Settings.svelte | 4 + src/lib/api.ts | 16 +-- src/lib/auth.ts | 12 +- src/lib/formatters.ts | 123 ++++++++++++-------- src/lib/github.ts | 7 +- src/lib/storage.ts | 2 + src/types.ts | 3 + yarn.lock | 116 +++++++++---------- 18 files changed, 327 insertions(+), 326 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4781b8f..aaa486a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 0.4.0 + +### Features +* change time stamp format to text +* add latest review text on notification + +### Fix +* on logout, disable auto start setting (this is bound to login) +* add link to user on domain +* update `text-ellipsis` for review list + ## 0.3.0 ### Features diff --git a/package.json b/package.json index 5092f43..31edada 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gitbar", "private": true, - "version": "0.3.0", + "version": "0.4.0", "type": "module", "scripts": { "dev": "vite", @@ -17,7 +17,7 @@ }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.2.0", - "@tauri-apps/cli": "^1.2.0", + "@tauri-apps/cli": "^1.2.1", "@tsconfig/svelte": "^3.0.0", "autoprefixer": "^10.4.13", "postcss": "^8.4.18", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index a5c3684..3767c7b 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -8,17 +8,11 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] @@ -178,9 +172,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] name = "cairo-rs" @@ -218,9 +212,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.76" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cesu8" @@ -246,7 +240,7 @@ checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" dependencies = [ "byteorder", "fnv", - "uuid 1.2.1", + "uuid 1.2.2", ] [[package]] @@ -397,9 +391,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" dependencies = [ "cfg-if", ] @@ -503,16 +497,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "deflate" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707b6a7b384888a70c8d2e8650b3e60170dfc6a67bb4aa67b6dfca57af4bedb4" -dependencies = [ - "adler32", - "byteorder", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -528,9 +512,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer", "crypto-common", @@ -652,12 +636,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ "crc32fast", - "miniz_oxide 0.5.4", + "miniz_oxide", ] [[package]] @@ -921,7 +905,7 @@ dependencies = [ [[package]] name = "gitbar" -version = "0.3.0" +version = "0.4.0" dependencies = [ "auto-launch", "cocoa", @@ -1126,12 +1110,12 @@ checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573" [[package]] name = "ico" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a4b3331534254a9b64095ae60d3dc2a8225a7a70229cd5888be127cdc1f6804" +checksum = "031530fe562d8c8d71c0635013d6d155bbfe8ba0aa4b4d2d24ce8af6b71047bd" dependencies = [ "byteorder", - "png 0.11.0", + "png", ] [[package]] @@ -1183,9 +1167,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", "hashbrown", @@ -1209,15 +1193,6 @@ dependencies = [ "cfb 0.7.3", ] -[[package]] -name = "inflate" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f9f47468e9a76a6452271efadc88fe865a82be91fe75e6c0c57b87ccea59d4" -dependencies = [ - "adler32", -] - [[package]] name = "instant" version = "0.1.12" @@ -1484,15 +1459,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "miniz_oxide" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.6.2" @@ -1591,17 +1557,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.4.1" @@ -1700,19 +1655,19 @@ checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "open" -version = "3.0.3" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a3100141f1733ea40b53381b0ae3117330735ef22309a190ac57b9576ea716" +checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8" dependencies = [ "pathdiff", - "windows-sys 0.36.1", + "windows-sys 0.42.0", ] [[package]] name = "openssl" -version = "0.10.42" +version = "0.10.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" +checksum = "020433887e44c27ff16365eaa2d380547a94544ad509aff6eb5b6e3e0b27b376" dependencies = [ "bitflags", "cfg-if", @@ -1742,9 +1697,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.77" +version = "0.9.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03b84c3b2d099b81f0953422b4d4ad58761589d0229b5506356afca05a3670a" +checksum = "07d5c8cb6e57b3a3612064d7b18b117912b4ce70955c2504d4b741c9e244b132" dependencies = [ "autocfg", "cc", @@ -1796,9 +1751,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" dependencies = [ "cfg-if", "libc", @@ -1827,9 +1782,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a528564cc62c19a7acac4d81e01f39e53e25e17b934878f4c6d25cc2836e62f8" +checksum = "5f400b0f7905bf702f9f3dc3df5a121b16c54e9e8012c082905fdf09a931861a" dependencies = [ "thiserror", "ucd-trie", @@ -1965,18 +1920,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "png" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b0cabbbd20c2d7f06dbf015e06aad59b6ca3d9ed14848783e98af9aaf19925" -dependencies = [ - "bitflags", - "deflate", - "inflate", - "num-iter", -] - [[package]] name = "png" version = "0.17.7" @@ -1986,7 +1929,7 @@ dependencies = [ "bitflags", "crc32fast", "flate2", - "miniz_oxide 0.6.2", + "miniz_oxide", ] [[package]] @@ -2377,18 +2320,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -2397,9 +2340,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ "itoa 1.0.4", "ryu", @@ -2622,9 +2565,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" dependencies = [ "proc-macro2", "quote", @@ -2659,9 +2602,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.15.3" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42c460173627564bde252ca5ebf346ba5b37c5cee1a445782bacc8e9b8d38b5e" +checksum = "8c8fab9f2ba9a6d7ad55b46f812984b6ab203d774c162163ac297edc9567404b" dependencies = [ "bitflags", "cairo-rs", @@ -2694,12 +2637,12 @@ dependencies = [ "once_cell", "parking_lot", "paste", - "png 0.17.7", + "png", "raw-window-handle", "scopeguard", "serde", "unicode-segmentation", - "uuid 1.2.1", + "uuid 1.2.2", "windows 0.39.0", "windows-implement", "x11-dl", @@ -2718,9 +2661,9 @@ dependencies = [ [[package]] name = "tauri" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac135e45c2923bd91edbb95a0d656f8d025389697e34d6d79166952bfa79c61c" +checksum = "18203448b9d4dcad55607eafeda6dc7fe135848e5f567cd8bdade6cafd8b1a85" dependencies = [ "anyhow", "attohttpc", @@ -2742,7 +2685,7 @@ dependencies = [ "once_cell", "open", "percent-encoding", - "png 0.17.7", + "png", "rand 0.8.5", "raw-window-handle", "regex", @@ -2762,7 +2705,7 @@ dependencies = [ "thiserror", "tokio", "url", - "uuid 1.2.1", + "uuid 1.2.2", "webkit2gtk", "webview2-com", "windows 0.39.0", @@ -2770,9 +2713,9 @@ dependencies = [ [[package]] name = "tauri-build" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef796f49abc98e6de0abe1b655120addc9d82363d8fc2304e71a4177c25e783c" +checksum = "8807c85d656b2b93927c19fe5a5f1f1f348f96c2de8b90763b3c2d561511f9b4" dependencies = [ "anyhow", "cargo_toml", @@ -2786,16 +2729,16 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb77cf7bfe3d8f886e73a7fa6157587d015c599671180b76595c1aef175ba8" +checksum = "14388d484b6b1b5dc0f6a7d6cc6433b3b230bec85eaa576adcdf3f9fafa49251" dependencies = [ "base64", "brotli", "ico", "json-patch", "plist", - "png 0.17.7", + "png", "proc-macro2", "quote", "regex", @@ -2806,15 +2749,15 @@ dependencies = [ "tauri-utils", "thiserror", "time", - "uuid 1.2.1", + "uuid 1.2.2", "walkdir", ] [[package]] name = "tauri-macros" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f24f481b0b2acfc288ac78755f00ebea53992c7365a165af64cb5ae00806edea" +checksum = "069319e5ecbe653a799b94b0690d9f9bf5d00f7b1d3989aa331c524d4e354075" dependencies = [ "heck 0.4.0", "proc-macro2", @@ -2826,9 +2769,9 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc5d54c476defa5436e70e0d0a06e3cb0f49b6f863895995d5e3769411769cf" +checksum = "c507d954d08ac8705d235bc70ec6975b9054fb95ff7823af72dbb04186596f3b" dependencies = [ "gtk", "http", @@ -2839,16 +2782,16 @@ dependencies = [ "serde_json", "tauri-utils", "thiserror", - "uuid 1.2.1", + "uuid 1.2.2", "webview2-com", "windows 0.39.0", ] [[package]] name = "tauri-runtime-wry" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78c55091701426c2519c7e9f1dc2dd33e533af4e75eae89cedc6995409351a2" +checksum = "7821c34cf1bd6d89ff46b46a53f3a5050d92afaf2053569f1cc4531167257b24" dependencies = [ "cocoa", "gtk", @@ -2857,7 +2800,7 @@ dependencies = [ "raw-window-handle", "tauri-runtime", "tauri-utils", - "uuid 1.2.1", + "uuid 1.2.2", "webkit2gtk", "webview2-com", "windows 0.39.0", @@ -2866,9 +2809,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d64c9a09ba1538b8e67ae8c78c10904f36ce38d364bf7f089ec807032a826b02" +checksum = "5abbc109a6eb45127956ffcc26ef0e875d160150ac16cfa45d26a6b2871686f1" dependencies = [ "brotli", "ctor", @@ -3007,9 +2950,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.21.2" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" dependencies = [ "autocfg", "bytes", @@ -3163,9 +3106,9 @@ checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "uuid" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" dependencies = [ "getrandom 0.2.8", ] @@ -3697,9 +3640,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.22.0" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "923d297b203eae65b095af16c02978b7932be1968012b4da7138390edf34dea5" +checksum = "e3b4906cc7b3c5959893f3984bb60882ec94539eb14622077e6529f5b3d008ee" dependencies = [ "base64", "block", @@ -3735,9 +3678,9 @@ dependencies = [ [[package]] name = "x11" -version = "2.20.0" +version = "2.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7ae97874a928d821b061fce3d1fc52f08071dd53c89a6102bc06efcac3b2908" +checksum = "c2638d5b9c17ac40575fb54bb461a4b1d2a8d1b4ffcc4ff237d254ec59ddeb82" dependencies = [ "libc", "pkg-config", @@ -3745,9 +3688,9 @@ dependencies = [ [[package]] name = "x11-dl" -version = "2.20.0" +version = "2.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c83627bc137605acc00bb399c7b908ef460b621fc37c953db2b09f88c449ea6" +checksum = "b1536d6965a5d4e573c7ef73a2c15ebcd0b2de3347bdf526c34c297c00ac40f0" dependencies = [ "lazy_static", "libc", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index f981691..5726c5d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitbar" -version = "0.3.0" +version = "0.4.0" description = "Github review counter" authors = ["mikael.kristiansson"] license = "MIT" @@ -12,14 +12,14 @@ rust-version = "1.57" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = { version = "1.2", features = [] } +tauri-build = { version = "1.2.1", features = [] } [dependencies] serde_json = "1.0" auto-launch = "0.3" thiserror = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.2", features = ["http-request", "icon-png", "notification-all", "shell-open", "system-tray"] } +tauri = { version = "1.2.1", features = ["http-request", "icon-png", "notification-all", "shell-open", "system-tray"] } [target.'cfg(target_os = "macos")'.dependencies] cocoa = "0.24" diff --git a/src-tauri/src/auto_start.rs b/src-tauri/src/auto_start.rs index 991f4d5..874c020 100644 --- a/src-tauri/src/auto_start.rs +++ b/src-tauri/src/auto_start.rs @@ -10,12 +10,6 @@ use std::env::current_exe; type Result = std::result::Result; -#[derive(Debug, Copy, Clone)] -pub enum MacosLauncher { - LaunchAgent, - AppleScript, -} - #[derive(Debug, thiserror::Error)] pub enum Error { #[error(transparent)] @@ -90,7 +84,6 @@ async fn is_enabled(manager: State<'_, AutoLaunchManager>) -> Result { /// /// `args` - are passed to your app on startup. pub fn init( - macos_launcher: MacosLauncher, args: Option>, ) -> TauriPlugin { Builder::new("autostart") @@ -102,13 +95,14 @@ pub fn init( if let Some(args) = args { builder.set_args(&args); } - builder.set_use_launch_agent(matches!(macos_launcher, MacosLauncher::LaunchAgent)); + 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 diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 5b6d9f8..8761360 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -7,7 +7,6 @@ use tauri::Manager; use tauri::{CustomMenuItem, SystemTray, SystemTrayEvent, SystemTrayMenu, PhysicalPosition}; mod auto_start; -use auto_start::MacosLauncher; #[cfg(target_os = "macos")] use cocoa::appkit::{NSWindow, NSWindowButton, NSWindowStyleMask, NSWindowTitleVisibility}; @@ -143,7 +142,6 @@ fn main() { }) .invoke_handler(tauri::generate_handler![set_review_count]) .plugin(auto_start::init( - MacosLauncher::LaunchAgent, None, )) .setup(|app| { diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 5d6ee09..590d1ec 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,8 +7,8 @@ "distDir": "../dist" }, "package": { - "productName": "Gitbar", - "version": "0.3.0" + "productName": "GitBar", + "version": "0.4.0" }, "tauri": { "allowlist": { @@ -39,7 +39,7 @@ "icons/icon.ico" ], "identifier": "com.gitbar.dev", - "longDescription": "", + "longDescription": "Github reviews in your system taskbar", "macOS": { "entitlements": null, "exceptionDomain": "", @@ -72,7 +72,7 @@ "fullscreen": false, "height": 400, "resizable": false, - "title": "Gitbar", + "title": "GitBar", "width": 500, "visible": false, "skipTaskbar": true, diff --git a/src/components/Footer.svelte b/src/components/Footer.svelte index 7cb7396..7c9911b 100644 --- a/src/components/Footer.svelte +++ b/src/components/Footer.svelte @@ -1,4 +1,5 @@ {#if loading} -
-
-
-
-
-
-
-
-
+
    +
  • +
    +
    +
    +
    +
    +
    +
    +
    +
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +
  • +
  • +
    +
    +
    +
    +
    +
    +
    +
    +
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +
  • +
  • +
    +
    +
    +
    +
    +
    +
    +
    +
    -
    -
    +
  • +
{:else if $github.reviews.count === 0}
  • onClick(review.node.url)} >
    @@ -114,20 +128,19 @@ >
    -
    +
    + {review.node.repository.nameWithOwner} - {review.node.repository.nameWithOwner} - {review.node.title} + {review.node.title}
    - #{review.node.number} opened on{' '} - {dateToString(review.node.createdAt, 'YYYY-MM-DD h:m')} by @{review - .node.author.login} + #{review.node.number} opened + {timeAgo(review.node.createdAt)} by @{review.node.author.login}
    diff --git a/src/components/Settings.svelte b/src/components/Settings.svelte index ce867df..cabc2a1 100644 --- a/src/components/Settings.svelte +++ b/src/components/Settings.svelte @@ -5,6 +5,7 @@ import Toggle from './Toggle.svelte'; import Range from './Range.svelte'; import Theme from './Theme.svelte'; + import { isEnabled } from '../lib/auto-start'; export let modalVisible: boolean; let openAtStartup = $auth.settings?.openAtStartup; @@ -28,6 +29,9 @@ const [name, version] = values; app = { name, version }; }); + isEnabled().then((active) => { + openAtStartup = active; + }); }); diff --git a/src/lib/api.ts b/src/lib/api.ts index 6fa3885..2bd8fc4 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -7,12 +7,7 @@ export const getUserData = async ( ): Promise => { const client = await getClient(); const response: { - data: { - id: number; - login: string; - name: string; - avatar_url: string; - }; + data: User; } = await client.get(`https://api.${hostname}/user`, { responseType: ResponseType.JSON, headers: { @@ -27,6 +22,9 @@ export const getUserData = async ( login: data.login, name: data.name, avatar_url: data.avatar_url, + html_url: data.html_url, + company: data.company, + email: data.email, }; }; @@ -49,11 +47,7 @@ export const getReviews = async (account: AuthState): Promise => { number url title - labels(first:100) { - nodes { - name - } - } + changedFiles } } } diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 4a1bc0f..bbb824d 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -34,13 +34,11 @@ const signOut = () => { }; const updateSettings = (data: SettingsState) => { - if (data['openAtStartup']) { - switch (data['openAtStartup'] as boolean) { - case true: - enable(); - case false: - disable(); - } + switch (data['openAtStartup'] as boolean) { + case true: + enable(); + case false: + disable(); } auth.update((prevAuth) => { const newSettings = { diff --git a/src/lib/formatters.ts b/src/lib/formatters.ts index d713227..d3dc43f 100644 --- a/src/lib/formatters.ts +++ b/src/lib/formatters.ts @@ -1,52 +1,79 @@ -type Dates = { - [key: string]: number; -}; - -function joinObj(obj: {}, separator: string) { - const out = []; - for (const k in obj) { - out.push(k); +const MONTH_NAMES = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', +]; + +function getFormattedDate( + date: Date, + preformattedDate: boolean | string = false, + hideYear = false +) { + const day = date.getDate(); + const month = MONTH_NAMES[date.getMonth()]; + const year = date.getFullYear(); + const hours = date.getHours(); + let minutes: string | number = date.getMinutes(); + + if (minutes < 10) { + // Adding leading zero to minutes + minutes = `0${minutes}`; + } + + if (preformattedDate) { + // Today at 10:20 + // Yesterday at 10:20 + return `${preformattedDate} at ${hours}:${minutes}`; + } + + if (hideYear) { + // 10. January at 10:20 + return `${day}. ${month} at ${hours}:${minutes}`; } - return out.join(separator); + + // 10. January 2017. at 10:20 + return `${day}. ${month} ${year}. at ${hours}:${minutes}`; } -export function dateToString(inDate: string, formatString = 'YYYY-MM-DD') { - const formatDate = new Date(inDate); - - const dateObject: Dates = { - M: formatDate.getMonth() + 1, - d: formatDate.getDate(), - D: formatDate.getDate(), - h: formatDate.getHours(), - m: formatDate.getMinutes(), - s: formatDate.getSeconds(), - y: formatDate.getFullYear(), - Y: formatDate.getFullYear(), - }; - // Build Regex Dynamically based on the list above. - // Should end up with something like this "/([Yy]+|M+|[Dd]+|h+|m+|s+)/g" - const dateMatchRegex = joinObj(dateObject, '+|') + '+'; - const regEx = new RegExp(dateMatchRegex, 'g'); - const outputDate = formatString.replace(regEx, function (formatToken: any) { - const target = formatToken.slice(-1) as string; - const datePartValue = dateObject[target]; - let tokenLength = formatToken.length; - - // A conflict exists between specifying 'd' for no zero pad -> expand to '10' and specifying yy for just two year digits '01' instead of '2001'. One expands, the other contracts. - // so Constrict Years but Expand All Else - if (formatToken.indexOf('y') < 0 && formatToken.indexOf('Y') < 0) { - // Expand single digit format token 'd' to multi digit value '10' when needed - tokenLength = Math.max( - formatToken.length, - datePartValue.toString().length - ); - } - const zeroPad = - datePartValue.toString().length < formatToken.length - ? '0'.repeat(tokenLength) - : ''; - return (zeroPad + datePartValue).slice(-tokenLength); - }); - - return outputDate; +export function timeAgo(dateParam: Date) { + if (!dateParam) { + return null; + } + + const date = typeof dateParam === 'object' ? dateParam : new Date(dateParam); + const DAY_IN_MS = 86400000; // 24 * 60 * 60 * 1000 + const today = new Date(); + const yesterday = new Date(today.getTime() - DAY_IN_MS); + const seconds = Math.round((today.getTime() - date.getTime()) / 1000); + const minutes = Math.round(seconds / 60); + const isToday = today.toDateString() === date.toDateString(); + const isYesterday = yesterday.toDateString() === date.toDateString(); + const isThisYear = today.getFullYear() === date.getFullYear(); + + if (seconds < 5) { + return 'now'; + } else if (seconds < 60) { + return `${seconds} seconds ago`; + } else if (seconds < 90) { + return 'about a minute ago'; + } else if (minutes < 60) { + return `${minutes} minutes ago`; + } else if (isToday) { + return getFormattedDate(date, 'Today'); // Today at 10:20 + } else if (isYesterday) { + return getFormattedDate(date, 'Yesterday'); // Yesterday at 10:20 + } else if (isThisYear) { + return getFormattedDate(date, false, true); // 10. January at 10:20 + } + + return getFormattedDate(date); // 10. January 2017. at 10:20 } diff --git a/src/lib/github.ts b/src/lib/github.ts index 8c81308..95ed458 100644 --- a/src/lib/github.ts +++ b/src/lib/github.ts @@ -21,7 +21,7 @@ async function notification(text: string) { } if (permissionGranted) { sendNotification({ - title: 'Gitbar', + title: 'GitBar', body: text, }); } @@ -41,8 +41,11 @@ const fetchReviews = async (account: AuthState) => { })); invoke('set_review_count', { count: String(res.issueCount) }); } + if (res.issueCount > prevCount) { - notification('A new PR is awaiting your review!'); + const title = res.edges[0].node.title; + const author = res.edges[0].node.author.login; + notification(`${title} - @${author}`); } }; diff --git a/src/lib/storage.ts b/src/lib/storage.ts index 516314e..229ad02 100644 --- a/src/lib/storage.ts +++ b/src/lib/storage.ts @@ -1,6 +1,7 @@ import type { AuthState, SettingsState } from '../types'; import { invoke } from '@tauri-apps/api'; import { github } from './github'; +import { disable } from './auto-start'; export const loadState = (): { account?: AuthState; @@ -29,4 +30,5 @@ export const clearState = (): void => { }, })); localStorage.clear(); + disable(); }; diff --git a/src/types.ts b/src/types.ts index 5c2760d..e6ae34d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,6 +3,9 @@ export interface User { name: string; id: number; avatar_url: string; + html_url?: string; + company?: string; + email?: string; } export interface AuthState { diff --git a/yarn.lock b/yarn.lock index b39ecd0..9e87757 100644 --- a/yarn.lock +++ b/yarn.lock @@ -68,65 +68,65 @@ resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-1.2.0.tgz#1f196b3e012971227f41b98214c846430a4eb477" integrity sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw== -"@tauri-apps/cli-darwin-arm64@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.2.0.tgz#33c4382d67cb7ba6b23fcdbcbb1db5edd0be6bb6" - integrity sha512-f3LR2RvTU2ulxYdK9Nc3vKaSpDChu52pz0BMWNrSs3dxs4WTVioie98Ufz+GorifkUp3sYXcJte3HzX6wH/QxQ== - -"@tauri-apps/cli-darwin-x64@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.2.0.tgz#53d1fda8f88452ebd0851895a48a2e41f6085625" - integrity sha512-m07QZaAZCtyobrjddfz/Rxf9GGutnBOpRMbNqVqCk0qKRJzHG1fIsLqkgZh6+qPv0zHpu7xi/FPcqTec72Cp8w== - -"@tauri-apps/cli-linux-arm-gnueabihf@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.2.0.tgz#d0d6ecfe55d74b2e8561fbfe78b62e6c5e6a92e8" - integrity sha512-Id9eF1JtthZRFVtXAAVtSlI3uMT8cJ7LYmCSIl3mAXEUeaPBxnUs1i9X6/J+2Ho3yLEuuOxJ7PaJd+4v8wnEeg== - -"@tauri-apps/cli-linux-arm64-gnu@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.2.0.tgz#0baaab9066333dab887d6ef8d2b53234f4b10858" - integrity sha512-NtfPkkpeMPl+i/tB/Fc8ST2rKO2vV8int/RkOvNGLCkhWcl4sbzKBol7tc4q8c8h0X7FXDcF1l/EOuGsZUAA5Q== - -"@tauri-apps/cli-linux-arm64-musl@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.2.0.tgz#56bd2fdcca7d5640965f23752effec9cde63b495" - integrity sha512-tz+mOOVsy/TMdq2WJVIJl/iwW3OCWCyD5Fls3fhyJ4XpLfjn4G+C+oU0awXD/0se0ko81aq4D+r8eDx6oBRi0A== - -"@tauri-apps/cli-linux-x64-gnu@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.2.0.tgz#e63ee7b28bc91ed595d2b15101596a9b109b7d6f" - integrity sha512-FH/wU+OWZjRQvrq/oequScr72I84XgOuRuMEpt/GqGD341cBJ8ithpoyzuiKsvjS6K0qMyRFzy3eyhQ7gwX+4Q== - -"@tauri-apps/cli-linux-x64-musl@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.2.0.tgz#01b02fc2e4837d47c78e968007c5294d53870154" - integrity sha512-nLg30aBT9fI83sjIqaGPN7twbtE5LJy2DbKzxIlw59F+GT8HBdiM/2mZdTLB3AQb52yVHuGB1TVtWDsl0JHqCA== - -"@tauri-apps/cli-win32-ia32-msvc@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.2.0.tgz#90b90e0050b786625999b083eb6be8e310307972" - integrity sha512-eXtgIgY0fawgcOuUjH8Y6PxwPxbK87Zl9XmA7Q0m58T7pIz+gcbgvtH8Bb+liYHoRYItIhQxVm+ui7Y59rI7Cg== - -"@tauri-apps/cli-win32-x64-msvc@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.2.0.tgz#e702784144a317248a72cf53442e27bc2c4be67b" - integrity sha512-egyM66R05AIbkaUDptpHurFTIYp3VM4H5OrRd3O2b0oXf8SoiXiyrHbQsHVHHDYyytKmwkdNqjdy+Vev/Vq25Q== - -"@tauri-apps/cli@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.2.0.tgz#421a40391e62662bd01e9b7cb8a0d88260c96ce8" - integrity sha512-DgUnk4p/atWHq2HUx9Vt+/LuRsx4iFlkzdZIUxtFWvpcZih2k0TzmHJbrhM1evh1/7a+SqiwDawmyf3Hz1HxXA== +"@tauri-apps/cli-darwin-arm64@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-1.2.1.tgz#e75d6582f76b6ef33f251f9b559e7692b7892faa" + integrity sha512-WiAxSON52owFI65Whd3NjcKjXdO1zJfafBVZ3v+Y3F2zlXhRPiirXbtefAc3mvN56zDz/pfi018Qb4XesuVzHA== + +"@tauri-apps/cli-darwin-x64@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-1.2.1.tgz#3fefdb0154d7d804ea1b08fad342abec625b36e4" + integrity sha512-jfumnrn7RYKVtDmHgrQhImoxpqT51bDrO4KxgpIXaYSaf6MdG2JT72dwUovPrURw0JX2Z/Elihq+dYbrsKoV/w== + +"@tauri-apps/cli-linux-arm-gnueabihf@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-1.2.1.tgz#6f5f403334b840d0085fec38cca4551c5c6b36a6" + integrity sha512-n4p6Ekn6Wa9X/klUGevEGgoWAGApGGsLrJYE4c8bKTbAUfQ9Nyzjh8gK/GDii1dg9oRW0FdXDa6BJa7aEEj9sA== + +"@tauri-apps/cli-linux-arm64-gnu@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-1.2.1.tgz#d1c536d0fe4819029de9132974bdfb6fa08e55a7" + integrity sha512-oAHkQQGfNCh8pQQHuDzzqt+S5sOj3tiUkySaquR2z/AQEHeDGAMrRGLZwOiDw9Xvu7qxFiF9H0e5OMK7BkncDw== + +"@tauri-apps/cli-linux-arm64-musl@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.2.1.tgz#22dd054d3ae2a923d5f7d3c7f529f48e7113ec19" + integrity sha512-1dEZ5fdFYkMyB1U7ZkDJUlwYwCeqy9Y3vXmtZ6pCxrvgs844s8+RIFDuMU42pTN+lUxfFeQARmv0LpS4eF/QWQ== + +"@tauri-apps/cli-linux-x64-gnu@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-1.2.1.tgz#bfe23577a46a74699b27714d82162f0ae9280090" + integrity sha512-wkgCD3s5P6tgBPnn0/gDx7MXMx2Hx+jdA+JP8zdCq4cIeYXlxdZG/zXbHb5ldPadNh582lzHiGg+Pmc+wDg2fA== + +"@tauri-apps/cli-linux-x64-musl@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-1.2.1.tgz#dce7fb0254a1975238bdde5882115b38271ec9b7" + integrity sha512-zD+a+5cSlYVU0ECOojWp71ok/9jE0DJufzb9oky17XIKV/oiOAG60z4OYRe+oqxYS1TcBt+pUa1/2zlu/6SRdA== + +"@tauri-apps/cli-win32-ia32-msvc@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-1.2.1.tgz#b6cb355f2d85704710c845800a29784536fb7240" + integrity sha512-nEgdRd8czaKL1RQfj946dsfzlk6atmD95Fm7NVTVOe77PFHTS3ztHeWK7X6jirCaOF3h/F7qpJVCU6JMnq2tfA== + +"@tauri-apps/cli-win32-x64-msvc@1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-1.2.1.tgz#b2b431ffed68fab9024d59ac2a2bafb02c5b9a5a" + integrity sha512-ceWiQkmNNRrnfgbLMnndT4QF1IyLK7aOJsMqS/HueshAwmVQWnC1DUE0C58Taetgq38Cavc4gGnZOCHuH6ZuTw== + +"@tauri-apps/cli@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-1.2.1.tgz#d7f61547915a8b052a92197ac70b8322838c6d2d" + integrity sha512-JrFFT1/4V+AGSRjKdgszZwOr+/a1519LDhNxBkbsIg6D/kFK+3kk1qImaQBY9DvvIWK6IV4whc8OAkgxm+Sl3w== optionalDependencies: - "@tauri-apps/cli-darwin-arm64" "1.2.0" - "@tauri-apps/cli-darwin-x64" "1.2.0" - "@tauri-apps/cli-linux-arm-gnueabihf" "1.2.0" - "@tauri-apps/cli-linux-arm64-gnu" "1.2.0" - "@tauri-apps/cli-linux-arm64-musl" "1.2.0" - "@tauri-apps/cli-linux-x64-gnu" "1.2.0" - "@tauri-apps/cli-linux-x64-musl" "1.2.0" - "@tauri-apps/cli-win32-ia32-msvc" "1.2.0" - "@tauri-apps/cli-win32-x64-msvc" "1.2.0" + "@tauri-apps/cli-darwin-arm64" "1.2.1" + "@tauri-apps/cli-darwin-x64" "1.2.1" + "@tauri-apps/cli-linux-arm-gnueabihf" "1.2.1" + "@tauri-apps/cli-linux-arm64-gnu" "1.2.1" + "@tauri-apps/cli-linux-arm64-musl" "1.2.1" + "@tauri-apps/cli-linux-x64-gnu" "1.2.1" + "@tauri-apps/cli-linux-x64-musl" "1.2.1" + "@tauri-apps/cli-win32-ia32-msvc" "1.2.1" + "@tauri-apps/cli-win32-x64-msvc" "1.2.1" "@tsconfig/svelte@^3.0.0": version "3.0.0"