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 6, 2023
1 parent 9a39445 commit d16a470
Show file tree
Hide file tree
Showing 11 changed files with 491 additions and 891 deletions.
3 changes: 2 additions & 1 deletion app/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
},
"dependencies": {
"@pomatez/shareables": "*",
"@tauri-apps/api": "2.0.0-alpha.8",
"@tauri-apps/plugin-autostart": "^2.0.0-alpha.1",
"@types/autosize": "^3.0.7",
"@types/jest": "^26.0.24",
"@types/node": "^14.18.63",
Expand All @@ -57,7 +59,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
16 changes: 8 additions & 8 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 @@ -32,8 +31,8 @@ export const TauriConnectorProvider: React.FC = ({ children }) => {
* @param payload
*/
const send = useCallback(
(event: string, ...payload: any) => {
invoke(event.toLowerCase(), ...payload);
async (event: string, ...payload: any) => {
await invoke(event.toLowerCase(), ...payload);
},
[invoke]
);
Expand All @@ -50,8 +49,9 @@ export const TauriConnectorProvider: React.FC = ({ children }) => {

const timer = useSelector((state: AppStateTypes) => state.timer);

const { count, duration, timerType, shouldFullscreen } =
useContext(CounterContext);
const { count, duration, timerType, shouldFullscreen } = useContext(
CounterContext
);
const dashOffset = (duration - count) * (24 / duration);

const onMinimizeCallback = useCallback(() => {
Expand Down Expand Up @@ -124,7 +124,7 @@ export const TauriConnectorProvider: React.FC = ({ children }) => {
const img = new Image();
img.src = svgXML;

img.onload = function () {
img.onload = function() {
ctx?.drawImage(img, 0, 0);
const dataUrl = canvas.toDataURL("image/png");

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 d16a470

Please sign in to comment.