Skip to content

Commit

Permalink
fix(tauri): links now open in the default browser
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Nov 12, 2023
1 parent 8adcd93 commit 901b824
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 44 deletions.
46 changes: 22 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,33 @@

## [1.4.0](https://github.com/zidoro/pomatez/compare/v1.3.1...v1.4.0) (2023-11-12)


### Features ✨

* add base tauri app ([8b91a3f](https://github.com/zidoro/pomatez/commit/8b91a3f898efa8f1775eb83b937f379a56d9c4da))
* make tauri version draggable ([6202477](https://github.com/zidoro/pomatez/commit/620247715b3fb0e21c0a68b4fd77470f30f60391))
* restructure connector in a way that allows easy switching out for platforms ([ce368dd](https://github.com/zidoro/pomatez/commit/ce368dd03b7edf3129acedbae1acabad059c2d67))
* **tauri:** add base connector with placeholders for logging ([a989379](https://github.com/zidoro/pomatez/commit/a989379a57c66078409169d325c61860b109c8fe))
* **tauri:** add closing logic ([5b7c749](https://github.com/zidoro/pomatez/commit/5b7c74958b216424ccb922a5e7c49df271d0f912))
* **tauri:** add easy command interface for frontend -> backend ([4483005](https://github.com/zidoro/pomatez/commit/44830057ee8a4a70c68677becab8a467c742d102))
* **tauri:** add global show and hide shortcuts as well as block reload ([ef17d00](https://github.com/zidoro/pomatez/commit/ef17d00c5ee5fc46fef7c409734b6524edc7acdb))
* **tauri:** add tray icon updating and a number of other commands ([61d3e2c](https://github.com/zidoro/pomatez/commit/61d3e2c00fb6c9e1a617802c7f6f283eb5793163))
* **tauri:** added connection hooks for all of the base tauri commands ([9ad7edc](https://github.com/zidoro/pomatez/commit/9ad7edcd3d6c3e212c4273e26d6ce2df8843a0dc))
* **tauri:** always on top command ([702f419](https://github.com/zidoro/pomatez/commit/702f4198548b0a2ba21cf1418f5849c969ff6cfb))
* **tauri:** auto updater ([02c6d00](https://github.com/zidoro/pomatez/commit/02c6d00e38c2eeb6ce3883709ae1b97b426ebf4d))
* **tauri:** compact mode resizing ([dc63f31](https://github.com/zidoro/pomatez/commit/dc63f31a3402aaa9b8ded51f6f804bf3607a8ae2))
* **tauri:** debug menu in dev mode ([c5289b9](https://github.com/zidoro/pomatez/commit/c5289b9c905e40e4d6dea9912d8f9f666fba977c))
* **tauri:** full screen mode ([d59ca69](https://github.com/zidoro/pomatez/commit/d59ca6946057360cb49427aba3584775c2c69e18))
* **tauri:** improve installer ([f9c8eb2](https://github.com/zidoro/pomatez/commit/f9c8eb283020f269928d4b65e72a39aa80ff0d4c))
* **tauri:** pass the data from the frontend into the commands ([58553d8](https://github.com/zidoro/pomatez/commit/58553d8d9072de3e6d461942799b322b4bbbb3ce))
* **tauri:** updater window ([2dfc795](https://github.com/zidoro/pomatez/commit/2dfc7952a1b46ff970a9020217e1211a6c210b2e))

- add base tauri app ([8b91a3f](https://github.com/zidoro/pomatez/commit/8b91a3f898efa8f1775eb83b937f379a56d9c4da))
- make tauri version draggable ([6202477](https://github.com/zidoro/pomatez/commit/620247715b3fb0e21c0a68b4fd77470f30f60391))
- restructure connector in a way that allows easy switching out for platforms ([ce368dd](https://github.com/zidoro/pomatez/commit/ce368dd03b7edf3129acedbae1acabad059c2d67))
- **tauri:** add base connector with placeholders for logging ([a989379](https://github.com/zidoro/pomatez/commit/a989379a57c66078409169d325c61860b109c8fe))
- **tauri:** add closing logic ([5b7c749](https://github.com/zidoro/pomatez/commit/5b7c74958b216424ccb922a5e7c49df271d0f912))
- **tauri:** add easy command interface for frontend -> backend ([4483005](https://github.com/zidoro/pomatez/commit/44830057ee8a4a70c68677becab8a467c742d102))
- **tauri:** add global show and hide shortcuts as well as block reload ([ef17d00](https://github.com/zidoro/pomatez/commit/ef17d00c5ee5fc46fef7c409734b6524edc7acdb))
- **tauri:** add tray icon updating and a number of other commands ([61d3e2c](https://github.com/zidoro/pomatez/commit/61d3e2c00fb6c9e1a617802c7f6f283eb5793163))
- **tauri:** added connection hooks for all of the base tauri commands ([9ad7edc](https://github.com/zidoro/pomatez/commit/9ad7edcd3d6c3e212c4273e26d6ce2df8843a0dc))
- **tauri:** always on top command ([702f419](https://github.com/zidoro/pomatez/commit/702f4198548b0a2ba21cf1418f5849c969ff6cfb))
- **tauri:** auto updater ([02c6d00](https://github.com/zidoro/pomatez/commit/02c6d00e38c2eeb6ce3883709ae1b97b426ebf4d))
- **tauri:** compact mode resizing ([dc63f31](https://github.com/zidoro/pomatez/commit/dc63f31a3402aaa9b8ded51f6f804bf3607a8ae2))
- **tauri:** debug menu in dev mode ([c5289b9](https://github.com/zidoro/pomatez/commit/c5289b9c905e40e4d6dea9912d8f9f666fba977c))
- **tauri:** full screen mode ([d59ca69](https://github.com/zidoro/pomatez/commit/d59ca6946057360cb49427aba3584775c2c69e18))
- **tauri:** improve installer ([f9c8eb2](https://github.com/zidoro/pomatez/commit/f9c8eb283020f269928d4b65e72a39aa80ff0d4c))
- **tauri:** pass the data from the frontend into the commands ([58553d8](https://github.com/zidoro/pomatez/commit/58553d8d9072de3e6d461942799b322b4bbbb3ce))
- **tauri:** updater window ([2dfc795](https://github.com/zidoro/pomatez/commit/2dfc7952a1b46ff970a9020217e1211a6c210b2e))

### Bug Fixes 🐛

* changing time configuration with keyboard did not work - [#402](https://github.com/zidoro/pomatez/issues/402) ([#489](https://github.com/zidoro/pomatez/issues/489)) ([b9b5248](https://github.com/zidoro/pomatez/commit/b9b524863d50905a756bbb1428fd87ed7f7c73e7))
* **tauri:** allow context menu on list titles ([a2ae285](https://github.com/zidoro/pomatez/commit/a2ae28569ea11074bc3413bda3f0085b39f7b369))
* **tauri:** catch audio playing errors gracefully ([f4f3274](https://github.com/zidoro/pomatez/commit/f4f3274881d1bbd40eea38bff72466dd25dbb18e))
* **tauri:** fullscreen break being resizeable ([aec8c3a](https://github.com/zidoro/pomatez/commit/aec8c3a73cf260192d1d4a33dc4071d7b592ba59))
* **tauri:** update to tauri v2 (fixes audio) ([231a379](https://github.com/zidoro/pomatez/commit/231a37903c7ff36b15025be98eaad7db1782446d))
- changing time configuration with keyboard did not work - [#402](https://github.com/zidoro/pomatez/issues/402) ([#489](https://github.com/zidoro/pomatez/issues/489)) ([b9b5248](https://github.com/zidoro/pomatez/commit/b9b524863d50905a756bbb1428fd87ed7f7c73e7))
- **tauri:** allow context menu on list titles ([a2ae285](https://github.com/zidoro/pomatez/commit/a2ae28569ea11074bc3413bda3f0085b39f7b369))
- **tauri:** catch audio playing errors gracefully ([f4f3274](https://github.com/zidoro/pomatez/commit/f4f3274881d1bbd40eea38bff72466dd25dbb18e))
- **tauri:** fullscreen break being resizeable ([aec8c3a](https://github.com/zidoro/pomatez/commit/aec8c3a73cf260192d1d4a33dc4071d7b592ba59))
- **tauri:** update to tauri v2 (fixes audio) ([231a379](https://github.com/zidoro/pomatez/commit/231a37903c7ff36b15025be98eaad7db1782446d))

## [1.3.1](https://github.com/zidoro/pomatez/compare/v1.3.0...v1.3.1) (2023-10-19)

Expand Down
1 change: 1 addition & 0 deletions app/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@tauri-apps/api": "2.0.0-alpha.11",
"@tauri-apps/plugin-autostart": "2.0.0-alpha.2",
"@tauri-apps/plugin-global-shortcut": "2.0.0-alpha.2",
"@tauri-apps/plugin-shell": "^2.0.0-alpha.3",
"@tauri-apps/plugin-window": "2.0.0-alpha.1",
"@types/autosize": "^3.0.7",
"@types/jest": "^26.0.24",
Expand Down
32 changes: 29 additions & 3 deletions app/renderer/src/contexts/connectors/TauriConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { TraySVG } from "../../components";
import { enable, disable } from "@tauri-apps/plugin-autostart";
import { invoke } from "@tauri-apps/api/primitives";
import { listen } from "@tauri-apps/api/event";
import { open } from "@tauri-apps/plugin-shell";
import { setUpdateBody, setUpdateVersion } from "../../store/update";

export const TauriInvokeConnector = {
Expand Down Expand Up @@ -54,6 +55,30 @@ export const TauriConnectorProvider: React.FC = ({ children }) => {
};
}, []);

/**
* Apparently you can just use _blank as the target though it definitely isn't working on windows.
*
* This is a workaround :)
*/
useEffect(() => {
function urlClickHandler(e: MouseEvent) {
const target = e.target as HTMLAnchorElement;
if (
target &&
target.tagName === "A" &&
target.href.startsWith("http") &&
target.target === "_blank"
) {
e.preventDefault();
open(target.href); // Use Tauri's shell module to open external links
}
}
window.addEventListener("click", urlClickHandler);
return () => {
window.removeEventListener("click", urlClickHandler);
};
}, []);

/**
* Rust uses lowercase snake_case for function names, so we need to convert to lower case for the calls.
* @param event
Expand All @@ -75,8 +100,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 @@ -149,7 +175,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
4 changes: 2 additions & 2 deletions app/renderer/src/routes/Config/ConfigSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const ConfigSlider: React.FC<ConfigSliderProps> = ({

/*
Check if "handleConfigChange" exists to avoid typescript compile error.
Error comes because type "ConfigSliderProps" is used in "src/config.ts" for "rangeConfig" object. But that object is not used by anything else in the app which means its unnecessary code.
Correct solution would be to make "handleConfigChange" mandatory instead of optional in "ConfigSliderProps" type & remove/disable the "rangeConfig" object from "src/config.ts".
*/

Expand Down
75 changes: 75 additions & 0 deletions app/tauri/Cargo.lock

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

1 change: 1 addition & 0 deletions app/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ tauri-plugin-autostart = "2.0.0-alpha.3"
lazy_static = "1.4.0"
base64 = { version = "0.21.4", features = [] }
tauri-plugin-notification = "2.0.0-alpha.5"
tauri-plugin-shell = "2.0.0-alpha.4"

# This one is for toying with global hotkeys from the browser mostly
# We can use https://github.com/tauri-apps/global-hotkey directly tbh
Expand Down
1 change: 1 addition & 0 deletions app/tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn main() {
let app = tauri::Builder::default()
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, None))
.plugin(tauri_plugin_window::init())
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.register_pomatez_commands()
Expand Down
13 changes: 2 additions & 11 deletions app/tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,9 @@
"signingIdentity": null
},
"publisher": "Roldan Montilla Jr",
"resources": [
"icons/icon.png"
],
"resources": ["icons/icon.png"],
"shortDescription": "",
"targets": [
"deb",
"appimage",
"msi",
"nsis",
"dmg",
"updater"
],
"targets": ["deb", "appimage", "msi", "nsis", "dmg", "updater"],
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
Expand Down
15 changes: 11 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3744,6 +3744,13 @@
dependencies:
"@tauri-apps/api" "2.0.0-alpha.9"

"@tauri-apps/plugin-shell@^2.0.0-alpha.3":
version "2.0.0-alpha.3"
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-shell/-/plugin-shell-2.0.0-alpha.3.tgz#f30aa7e2529794ea3dd6f1b6af79756b2fc27312"
integrity sha512-v4qLTE9DfzpYdcjZq3ASOC7gFtMtzIDWN5Bo2FheB+pHQvDRq8mrP8gTdkL4/9pQaOFlB0B+MKCwANYhD1jLEQ==
dependencies:
"@tauri-apps/api" "2.0.0-alpha.11"

"@tauri-apps/[email protected]":
version "2.0.0-alpha.1"
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-window/-/plugin-window-2.0.0-alpha.1.tgz#28a0217100fc5a34fb2a6d76103ba056b2348286"
Expand Down Expand Up @@ -14923,10 +14930,10 @@ react-dom@^16.14.0:
prop-types "^15.6.2"
scheduler "^0.19.1"

react-error-overlay@6.0.9, react-error-overlay@^6.0.11:
version "6.0.9"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
react-error-overlay@^6.0.11:
version "6.0.11"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb"
integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==

react-is@^16.12.0, react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.6:
version "16.13.1"
Expand Down

0 comments on commit 901b824

Please sign in to comment.