Skip to content

Commit

Permalink
New config files, switching to more profess. branching and tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
NateTheDev1 committed Sep 17, 2022
1 parent 295ceae commit 9cda874
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 28 deletions.
20 changes: 20 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.next
next-env.d.ts
node_modules
yarn.lock
package-lock.json
public
kube
.git
.husky
.vscode
env
.babelrc
.dockerignore
.env.template
.eslintrc.json
.eslintignore
.swc
.po
locales
.json
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"arrowParens": "avoid",
"jsxSingleQuote": false,
"trailingComma": "none"
}
38 changes: 27 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
},
"dependencies": {
"@tauri-apps/api": "^1.0.2",
"@tauri-apps/tauri-forage": "^1.0.0-beta.2",
"eventemitter3": "^4.0.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-modal": "^3.15.1",
"react-tooltip": "^4.2.21",
"recoil": "^0.7.5",
"style-it": "^2.1.4"
"style-it": "^2.1.4",
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#dev"
},
"devDependencies": {
"@tauri-apps/cli": "^1.1.1",
Expand All @@ -43,4 +43,4 @@
"vite": "^3.0.2",
"watch": "^1.0.2"
}
}
}
13 changes: 13 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0", features = ["api-all", "devtools"] }
window-shadows = "0.1.0"

[dependencies.tauri-plugin-store]
git = "https://github.com/tauri-apps/tauri-plugin-store"
branch = "dev"

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
)]

use tauri::Manager;
use tauri_plugin_store::PluginBuilder;
use window_shadows::set_shadow;

fn main() {
tauri::Builder::default()
.plugin(PluginBuilder::default().build())
.setup(|app| {
let window = app.get_window("main").unwrap();
set_shadow(&window, true).expect("Unsupported platform!");
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"windows": [
{
"decorations": false,
"height": 1200,
"height": 900,
"width": 800,
"resizable": true,
"title": "pluto",
Expand Down
33 changes: 20 additions & 13 deletions src/lib/PlutoLib.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { fs } from "@tauri-apps/api";
import { BaseDirectory } from "@tauri-apps/api/fs";
import { configDir, resourceDir } from "@tauri-apps/api/path";
import { THEME_AVAILABILITY } from "./theming/Theme.types";
import { ThemeManager } from "./theming/ThemeManager";
import { AppVersion, PlutoSettings } from "./types/generic";
import { forage } from "@tauri-apps/tauri-forage";
import { Store } from "tauri-plugin-store-api";

export class PlutoLib {
store!: Store;
settings?: PlutoSettings;
version!: AppVersion;
Theme!: ThemeManager;

constructor() {}
constructor() {
this.store = new Store(".pluto_settings.json");

console.info("User Settings Store: " + this.store.path);
}

async init() {
await this.store.save();
await this.load_version();
await this.settings_check();

Expand All @@ -25,7 +30,7 @@ export class PlutoLib {
}

async settings_check() {
let hasSettings = await forage.getItem({ key: "settings" })();
let hasSettings = await this.store.get("settings");

if (!hasSettings) {
console.info("No Settings Config Found. Starting Build");
Expand All @@ -37,26 +42,28 @@ export class PlutoLib {

this.settings = stngs;

await forage.setItem({
key: "settings",
value: JSON.stringify(stngs),
});
await this.store.set("settings", JSON.stringify(stngs));
} else {
await this.load_settings();
}
}

async load_settings() {
const setting = await forage.getItem({ key: "settings" })();
const setting = await this.store.get("settings");

this.settings = JSON.parse(setting as unknown as string);
}

async reset_settings() {
await this.store.reset();

this.settings_check();
}

async save_settings() {
await forage.setItem({
key: "settings",
value: JSON.stringify(this.settings),
})();
await this.store.set("settings", JSON.stringify(this.settings));

await this.store.save();

this.settings_check();
}
Expand Down

0 comments on commit 9cda874

Please sign in to comment.