Skip to content

Commit

Permalink
fix(tauri): update to tauri v2 (fixes audio)
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Oct 7, 2023
1 parent 9a39445 commit 10885a4
Show file tree
Hide file tree
Showing 13 changed files with 516 additions and 915 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ yarn-error.log*

.idea/
*.iml
/lerna-debug.log
4 changes: 3 additions & 1 deletion app/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
},
"dependencies": {
"@pomatez/shareables": "*",
"@tauri-apps/api": "2.0.0-alpha.8",
"@tauri-apps/plugin-autostart": "^2.0.0-alpha.1",
"@tauri-apps/plugin-window": "^2.0.0-alpha.1",
"@types/autosize": "^3.0.7",
"@types/jest": "^26.0.24",
"@types/node": "^14.18.63",
Expand All @@ -57,7 +60,6 @@
"redux-devtools-extension": "^2.13.8",
"redux-undo": "^1.0.1",
"styled-components": "^5.3.11",
"tauri-plugin-autostart-api": "https://github.com/tauri-apps/tauri-plugin-autostart#v1",
"use-stay-awake": "^0.1.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: 'unsafe-inline'">
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: 'unsafe-inline'; connect-src 'self' http://ipc.localhost/">
<title>Pomatez</title>
</head>
<body>
Expand Down
7 changes: 4 additions & 3 deletions app/renderer/src/components/Titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ type Props = {
};

const Titlebar: React.FC<Props> = ({ darkMode, timerType }) => {
const { onMinimizeCallback, onExitCallback } =
useContext(ConnnectorContext);
const { onMinimizeCallback, onExitCallback } = useContext(
ConnnectorContext
);

const getAppIcon = useCallback(() => {
switch (timerType) {
Expand All @@ -44,7 +45,7 @@ const Titlebar: React.FC<Props> = ({ darkMode, timerType }) => {
}, [darkMode, timerType]);

return (
<StyledTitlebar data-tauri-drag-region={true}>
<StyledTitlebar data-tauri-drag-region>
<StyledMarkWrapper>
<StyledMarkLogo src={getAppIcon()} />
<StyledMarkName>
Expand Down
14 changes: 5 additions & 9 deletions app/renderer/src/contexts/connectors/TauriConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ import {
} from "@pomatez/shareables";
import { encodeSvg } from "../../utils";
import { TraySVG } from "../../components";
import { enable, disable } from "tauri-plugin-autostart-api";
import { enable, disable } from "@tauri-apps/plugin-autostart";
import { invoke } from "@tauri-apps/api/tauri";

export const TauriConnectorProvider: React.FC = ({ children }) => {
const { invoke } = window.__TAURI__;

const settings: SettingTypes = useSelector(
(state: AppStateTypes) => state.settings
);
Expand All @@ -31,12 +30,9 @@ export const TauriConnectorProvider: React.FC = ({ children }) => {
* @param event
* @param payload
*/
const send = useCallback(
(event: string, ...payload: any) => {
invoke(event.toLowerCase(), ...payload);
},
[invoke]
);
const send = useCallback(async (event: string, ...payload: any) => {
await invoke(event.toLowerCase(), ...payload);
}, []);

useEffect(() => {
if (settings.openAtLogin) {
Expand Down
3 changes: 0 additions & 3 deletions app/renderer/src/extensions/window.extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ declare global {
options?: Electron.OpenExternalOptions
) => Promise<void>;
};
__TAURI__: {
invoke: (command: string, ...args: any[]) => void;
};
}
}

Expand Down
Loading

0 comments on commit 10885a4

Please sign in to comment.