Skip to content

Commit

Permalink
Show application meta information at settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
parksb committed Aug 27, 2023
1 parent 352a247 commit e923600
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.4", features = [] }

[dependencies]
tauri = { version = "1.4", features = [ "dialog-confirm", "dialog-ask", "notification-all", "shell-open"] }
tauri = { version = "1.4", features = [ "path-all", "dialog-confirm", "dialog-ask", "notification-all", "shell-open"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] }
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"dialog": {
"ask": true,
"confirm": true
},
"path": {
"all": true
}
},
"bundle": {
Expand Down
30 changes: 29 additions & 1 deletion src/routes/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { getVersion } from '@tauri-apps/api/app';
import { appDataDir } from '@tauri-apps/api/path';

import { createSignal, For, Match, onMount, Show, Switch } from "solid-js";

import "../styles/Settings.css";
import * as api from "../api/settings";

function Settings() {
const [version, setVersion] = createSignal("");
const [latestVersion, setLatestVersion] = createSignal("");
const [dataDir, setDataDir] = createSignal("");

const [settings, setSettings] = createSignal<api.Setting[]>([]);
const [newSettings, setNewSettings] = createSignal<{ [key in api.SettingKey]: string }>({
[api.SettingKey.POLLING_FREQUENCY]: "",
[api.SettingKey.NOTIFICATION]: "",
[api.SettingKey.DB_SCHEME_VERSION]: "",
[api.SettingKey.THEME]: "",
[api.SettingKey.ITEMS_ORDER]: "",
});

const keyToText = (key: api.SettingKey) => {
Expand Down Expand Up @@ -63,7 +71,21 @@ function Settings() {
</Show>;

onMount(async () => {
await load();
const fetchLatestVersion = async (): Promise<string> => {
const res = await fetch("https://api.github.com/repos/parksb/collie/releases/latest");
return (await res.json())['tag_name'];
};

const [fetchedVersion, fetchedLatestVersion, fetchedDataDir] = await Promise.all([
getVersion(),
fetchLatestVersion(),
appDataDir(),
load(),
]);

setVersion(fetchedVersion);
setLatestVersion(fetchedLatestVersion);
setDataDir(fetchedDataDir);

let newSettingsPlaceholder = newSettings();
settings().forEach((setting: api.Setting) => {
Expand Down Expand Up @@ -109,6 +131,12 @@ function Settings() {
</Switch>
</li>
}</For>
<li>
<strong>Current version</strong>: v{version()}
<small>Latest version: <a href="https://github.com/parksb/collie/releases/latest"
target="_blank">{latestVersion()}</a></small>
</li>
<li><strong>Data directory</strong>: {dataDir()}</li>
</ul>
</div>
);
Expand Down

0 comments on commit e923600

Please sign in to comment.