Skip to content

Commit 25d48fb

Browse files
authored
Merge pull request #6 from clearfeld/main
v.0.6.0
2 parents e78204a + 373e059 commit 25d48fb

File tree

7 files changed

+219
-223
lines changed

7 files changed

+219
-223
lines changed

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "construct"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
description = "A GUI API Client"
55
authors = ["clearfeld"]
66
edition = "2021"

src-tauri/capabilities/desktop.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
"permissions": [
1212
"updater:default",
1313
"updater:default",
14-
{
15-
"identifier": "fs:allow-exists",
16-
"allow": [{ "path": "$APPDATA/*" }]
17-
},
18-
"fs:allow-appdata-read",
14+
"fs:allow-exists",
1915
"fs:allow-appdata-read-recursive",
20-
"fs:allow-appdata-write",
21-
"fs:allow-appdata-write-recursive"
16+
"fs:allow-appdata-write-recursive",
17+
"core:window:allow-destroy"
2218
]
2319
}

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "construct",
4-
"version": "0.5.0",
4+
"version": "0.6.0",
55
"identifier": "com.construct.app",
66
"build": {
77
"beforeDevCommand": "pnpm dev",

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ function App() {
6161
path="/"
6262
element={
6363
<div>
64-
<SessionSaveAndLoadManager />
65-
6664
<div
6765
style={{
6866
height: "var(--navbar-height)",
@@ -71,6 +69,8 @@ function App() {
7169
<Navbar />
7270
</div>
7371

72+
<SessionSaveAndLoadManager />
73+
7474
<Outlet />
7575

7676
{/* <main className="container">

src/SessionSaveAndLoadManager.tsx

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
import {
2-
exists,
3-
BaseDirectory,
4-
readTextFile,
5-
} from "@tauri-apps/plugin-fs";
6-
import { useEffect } from "react";
1+
import * as stylex from "@stylexjs/stylex";
2+
import { exists, BaseDirectory, readTextFile } from "@tauri-apps/plugin-fs";
3+
import { useEffect, useState } from "react";
74
import useRequestStore from "./stores/request_store/index.ts";
85
import { useNavigate } from "react-router";
9-
10-
// TODO: have different file for local and prod version of app
11-
const session_file = "last_session.json";
12-
13-
// import { listen } from "@tauri-apps/api/event";
6+
import { LoadingSize, LoadingSpinner } from "@controlkit/ui";
7+
import { appDataDir } from "@tauri-apps/api/path";
8+
9+
const session_file = import.meta.env.DEV ? "last_session_dev_mode.json" : "last_session.json";
10+
const roaming_dir = await appDataDir(); // "com.construct.app";
11+
12+
const styles = stylex.create({
13+
wrapper: {
14+
backgroundColor: "var(--color-bg)",
15+
position: "absolute",
16+
width: "100%",
17+
height: "calc(100% - var(--navbar-height))",
18+
zIndex: 1000,
19+
display: "flex",
20+
flexDirection: "column",
21+
gap: "1rem",
22+
justifyContent: "center",
23+
alignItems: "center",
24+
},
25+
});
1426

1527
export default function SessionSaveAndLoadManager() {
1628
const navigate = useNavigate();
1729

30+
const [loading, setLoading] = useState<boolean>(true);
31+
1832
const setAllDataFromSessionSave = useRequestStore(
1933
(state) => state.setAllDataFromSessionSave,
2034
);
@@ -44,10 +58,8 @@ export default function SessionSaveAndLoadManager() {
4458
// }
4559
// };
4660

47-
// // TODO: need to figure this out in case of alt f4 or other types of window close events
48-
// // listen("tauri://close-requested", async (event) => {
49-
// // await AttemptToSaveLocalSession();
50-
// // });
61+
// TODO: need to figure this out in case of alt f4 or other types of window close events
62+
5163

5264
// window.addEventListener("keydown", handleKeyDown);
5365

@@ -56,20 +68,19 @@ export default function SessionSaveAndLoadManager() {
5668
// };
5769
}, []);
5870

59-
6071
async function SetLocalSessionIfExists() {
6172
// TODO: https://tauri.app/plugin/file-system/#read
6273
// probably should use readTextFileLines or Binary data format for session file instead of raw json
6374
// but its fine for now
6475

6576
// TODO: create a separate file within appConfig for settings store in the future
6677

67-
const previous_session_exists = await exists(session_file, {
78+
const previous_session_exists = await exists(`${roaming_dir}/${session_file}`, {
6879
baseDir: BaseDirectory.AppData,
6980
});
7081

7182
if (previous_session_exists) {
72-
const session_json = await readTextFile(session_file, {
83+
const session_json = await readTextFile(`${roaming_dir}/${session_file}`, {
7384
baseDir: BaseDirectory.AppData,
7485
});
7586

@@ -95,8 +106,18 @@ export default function SessionSaveAndLoadManager() {
95106
} else {
96107
console.log("doesnt exists");
97108
}
109+
110+
setLoading(false);
98111
}
99112

100-
return <></>;
113+
return (
114+
<>
115+
{loading && (
116+
<div {...stylex.props(styles.wrapper)}>
117+
<LoadingSpinner size={LoadingSize.LARGE} />
118+
<p>Checking for local session...</p>
119+
</div>
120+
)}
121+
</>
122+
);
101123
}
102-

0 commit comments

Comments
 (0)