Skip to content

Commit

Permalink
refactor: Update usage of platform plugin in store.ts and platform.pr…
Browse files Browse the repository at this point in the history
…ovider
  • Loading branch information
pacholoamit committed Oct 14, 2024
1 parent 75637dd commit 848c8a9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@tauri-apps/plugin-autostart": "~2",
"@tauri-apps/plugin-fs": "^2.0.0",
"@tauri-apps/plugin-log": "~2",
"@tauri-apps/plugin-os": "~2.0.0",
"@tauri-apps/plugin-os": "~2",
"@tauri-apps/plugin-process": "^2.0.0",
"@tauri-apps/plugin-shell": "^2.0.0",
"@tauri-apps/plugin-store": "~2",
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::time::Duration;

fn build_and_run_app(app: AppState) {
tauri::Builder::default()
.plugin(tauri_plugin_os::init())
.setup(|app| {
let handle = app.handle().clone();
let state = AppState::new();
Expand Down
2 changes: 1 addition & 1 deletion src/components/area-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const useAreaChartState = (
title: {
text: null,
},
startOnTick: true,
// startOnTick: true,
endOnTick: true,

gridLineColor: other.charts.area.default.gridLineColor,
Expand Down
5 changes: 2 additions & 3 deletions src/lib/store.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import logger from '@/lib/logger';
import { appDataDir } from '@tauri-apps/api/path';
import { platform } from '@tauri-apps/plugin-os';
import { createStore as createTauriStore } from '@tauri-apps/plugin-store';

const { platform } = window.__TAURI__.os;

// Generic function to create get/set operations
const createStoreItem = <T>(store: Awaited<ReturnType<typeof createTauriStore>>, key: string, defaultValue: T) => ({
get: async () => {
Expand Down Expand Up @@ -36,7 +35,7 @@ const isFirstRun = (store: Awaited<ReturnType<typeof createTauriStore>>) => ({
});

const createStore = async (name: string) => {
const currentPlatform = await platform();
const currentPlatform = platform();
const path = await appDataDir();
const storePath = currentPlatform === "windows" ? `${path}\\${name}` : `${path}/${name}`;
const store = await createTauriStore(storePath);
Expand Down
6 changes: 2 additions & 4 deletions src/providers/platform.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import useIsFirstRun from '@/hooks/useIsFirstRun';
import { streams } from '@/lib';
import store from '@/lib/store';
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
import { Platform } from '@tauri-apps/plugin-os';

const { platform: obtainPlatform } = window.__TAURI__.os;
import { Platform, platform } from '@tauri-apps/plugin-os';

interface PlatformProviderProps {
children: React.ReactNode;
Expand Down Expand Up @@ -48,7 +46,7 @@ const PlatformProvider: React.FC<PlatformProviderProps> = ({ children }) => {

useEffectAsync(async () => {
const appStore = await store;
const p = obtainPlatform();
const p = platform();
setPlatform(p);

console.log("Platform: ", p);
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3252,7 +3252,7 @@ __metadata:
languageName: node
linkType: hard

"@tauri-apps/plugin-os@npm:~2.0.0":
"@tauri-apps/plugin-os@npm:~2":
version: 2.0.0
resolution: "@tauri-apps/plugin-os@npm:2.0.0"
dependencies:
Expand Down Expand Up @@ -6886,7 +6886,7 @@ __metadata:
"@tauri-apps/plugin-autostart": ~2
"@tauri-apps/plugin-fs": ^2.0.0
"@tauri-apps/plugin-log": ~2
"@tauri-apps/plugin-os": ~2.0.0
"@tauri-apps/plugin-os": ~2
"@tauri-apps/plugin-process": ^2.0.0
"@tauri-apps/plugin-shell": ^2.0.0
"@tauri-apps/plugin-store": ~2
Expand Down

0 comments on commit 848c8a9

Please sign in to comment.