Skip to content

Commit

Permalink
checkpint
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacksore committed Aug 31, 2024
1 parent d2cb460 commit 1e2c9d8
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 127 deletions.
6 changes: 2 additions & 4 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"@tauri-apps/plugin-global-shortcut": "2.0.0-rc.0",
"@tauri-apps/plugin-websocket": "2.0.0-rc.0",
"@tauri-apps/plugin-window-state": "2.0.0-rc.0",
"@tauri-apps/plugin-store": "2.0.0-rc.0",
"@tauri-apps/plugin-log": "2.0.0-rc.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"date-fns": "^2.30.0",
Expand All @@ -54,10 +56,6 @@
"react-router-dom": "^6.22.3",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7",
"tauri-plugin-log": "github:tauri-apps/tauri-plugin-log#v1",
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#v1",
"tauri-plugin-websocket-api": "github:tauri-apps/tauri-plugin-websocket#v1",
"tauri-plugin-window-state-api": "github:tauri-apps/tauri-plugin-window-state#v1",
"uuid": "^9.0.1",
"zustand": "^4.5.2"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/hooks/use-config-value.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Store } from "tauri-plugin-store-api";
import { Store } from "@tauri-apps/plugin-store";
import { useEffect, useState } from "react";
import { DEFAULT_OVERLAYED_CONFIG, type OverlayedConfig, type OverlayedConfigKey } from "@/config";

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { axiom } from "@/axiom";
import { Store } from "tauri-plugin-store-api";
import { Store } from "@tauri-apps/plugin-store";

const store = new Store("config.json");

Expand Down
3 changes: 1 addition & 2 deletions apps/desktop/src/views/settings/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { saveWindowState, StateFlags } from "@tauri-apps/plugin-window-state";

import { invoke } from "@tauri-apps/api/core";
import { usePlatformInfo } from "@/hooks/use-platform-info";
import { Store } from "tauri-plugin-store-api";
import { Store } from "@tauri-apps/plugin-store";

import {
Dialog,
Expand All @@ -19,7 +19,6 @@ import {
} from "@/components/ui/dialog";
import { useEffect, useState } from "react";
import { Checkbox } from "@/components/ui/checkbox";
import { emit } from "@tauri-apps/api/event";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import type { VoiceUser } from "@/types";
import { useConfigValue } from "@/hooks/use-config-value";
Expand Down
16 changes: 10 additions & 6 deletions apps/desktop/src/views/settings/join-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import { Event } from "@/constants";
import { useToast } from "@/components/ui/use-toast";
import { requestPermission, sendNotification } from "@tauri-apps/plugin-notification";
import { Checkbox } from "@/components/ui/checkbox";
import { Store } from "tauri-plugin-store-api";
import Config from "@/config";
import type { JoinHistoryLogUser } from "@/types";
import { emit } from "@tauri-apps/api/event";
import { useConfigValue } from "@/hooks/use-config-value";
import { emit } from "@tauri-apps/api/event";

const MAX_LOG_LENGTH = 420;

const store = new Store("config.json");
export const JoinHistory = () => {
const [userLog, setUserLog] = useState<JoinHistoryLogUser[]>([]);
const { value: joinHistoryNotifications } = useConfigValue("joinHistoryNotifications");
Expand Down Expand Up @@ -52,6 +51,12 @@ export const JoinHistory = () => {
});
}, []);

// keep the notifications toggle in sync with the config
useEffect(() => {
// HACK: add a ref to avoid stale closure
notificationsEnabledRef.current = joinHistoryNotifications;
}, [joinHistoryNotifications]);

const resetUserLog = () => {
setUserLog([]);
};
Expand All @@ -67,9 +72,8 @@ export const JoinHistory = () => {
id="notification"
checked={joinHistoryNotifications}
onCheckedChange={async () => {
const newValue = !joinHistoryNotifications;
await store.set("joinHistoryNotifications", newValue);
await store.save();
await Config.set("joinHistoryNotifications", !joinHistoryNotifications);
await emit("config_update", await Config.getConfig());
}}
/>
<label
Expand Down
Loading

0 comments on commit 1e2c9d8

Please sign in to comment.