From 39d8f351698c36875b47f46020e56b982b48a418 Mon Sep 17 00:00:00 2001 From: Vincent Jousse Date: Tue, 21 May 2024 14:03:04 +0200 Subject: [PATCH] feat: add version number --- src-elm/Main.elm | 24 ++++++++++++++++++------ src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 3 +++ src-ts/main.ts | 2 ++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src-elm/Main.elm b/src-elm/Main.elm index 1772d77..f2c2f91 100644 --- a/src-elm/Main.elm +++ b/src-elm/Main.elm @@ -25,7 +25,8 @@ type alias Seconds = type alias Model = - { config : Config + { appVersion : String + , config : Config , currentColor : Color , currentRoundNumber : Int , currentSessionType : SessionType @@ -166,6 +167,7 @@ type alias Defaults = type alias Flags = { alwaysOnTop : Bool + , appVersion : String , autoStartWorkTimer : Bool , autoStartBreakTimer : Bool , desktopNotifications : Bool @@ -224,7 +226,8 @@ init flags = , playTick = False } in - ( { config = + ( { appVersion = flags.appVersion + , config = { alwaysOnTop = flags.alwaysOnTop , autoStartWorkTimer = flags.autoStartWorkTimer , autoStartBreakTimer = flags.autoStartBreakTimer @@ -1565,13 +1568,22 @@ settingsSettingView model = ] -aboutSettingView : Html Msg -aboutSettingView = +aboutSettingView : String -> Html Msg +aboutSettingView appVersion = div [ class "container", id "about" ] [ p [ class "drawer-heading" ] [ text "About" ] , section [] [ h2 [] [ text "Pomodrolm" ] - , p [ class "label" ] [ text "Version: dev" ] + , p [ class "label" ] + [ text <| "Version: " ++ appVersion ++ " " + , a + [ href <| "https://github.com/vjousse/pomodorolm/releases/tag/app-v" ++ appVersion + , class "label" + , class "link" + , target "_blank" + ] + [ text "(release notes)" ] + ] , p [ class "label" ] [ a [ href "https://github.com/vjousse/pomodorolm" @@ -1598,7 +1610,7 @@ drawerView model = settingsSettingView model AboutTab -> - aboutSettingView + aboutSettingView model.appVersion , div [ class "drawer-menu" ] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 7273d95..2c0de06 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "1.5.1", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.6.1", features = [ "window-start-dragging", "fs-read-file", "system-tray", "shell-all", "icon-png", "devtools", "notification"] } +tauri = { version = "1.6.1", features = [ "app-all", "window-start-dragging", "fs-read-file", "system-tray", "shell-all", "icon-png", "devtools", "notification"] } image = { version = "0.25", features = ["png"] } tempfile = "3.10.1" tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 0c4d928..4d4d378 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -13,6 +13,9 @@ "tauri": { "allowlist": { "all": false, + "app": { + "all": true + }, "shell": { "all": true, "execute": true, diff --git a/src-ts/main.ts b/src-ts/main.ts index 9ca3b2f..7d398b0 100644 --- a/src-ts/main.ts +++ b/src-ts/main.ts @@ -6,6 +6,7 @@ import { invoke } from "@tauri-apps/api"; import { listen } from "@tauri-apps/api/event"; import { attachConsole, info } from "tauri-plugin-log-api"; +import { getVersion } from "@tauri-apps/api/app"; // Display logs in the webview inspector attachConsole(); @@ -83,6 +84,7 @@ const app = Elm.Main.init({ node: root, flags: { alwaysOnTop: rustConfig.always_on_top, + appVersion: await getVersion(), autoStartWorkTimer: rustConfig.auto_start_work_timer, autoStartBreakTimer: rustConfig.auto_start_break_timer, desktopNotifications: rustConfig.desktop_notifications,