Skip to content

Commit

Permalink
Force unpin when error (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacksore authored Jul 3, 2024
1 parent b926d7d commit 5d70750
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- name: Cargo format
if: steps.changes.outputs.desktop == 'true'
run: cargo fmt --check
working-directory: apps/desktop/src-tauri

build-tauri:
name: Build (${{ matrix.settings.os }})
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/nav-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const NavBar = ({
<Pin
size={20}
onClick={async () => {
invoke("toggle_pin");
await invoke("toggle_pin");
await Config.set("pin", !pin);
navigate("/channel");
}}
Expand Down
14 changes: 14 additions & 0 deletions apps/desktop/src/rpc/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Event } from "@/constants";
import type { VoiceUser } from "@/types";
import { getVersion } from "@tauri-apps/api/app";
import { hash } from "@/utils/crypto";
import { invoke } from "@tauri-apps/api";

interface TokenResponse {
access_token: string;
Expand Down Expand Up @@ -121,6 +122,8 @@ class SocketManager {
console.log(e);
this.isConnected = false;
this.navigate("/error");

await this.unpin();
}

// subscribe to local storage events to see if we need to move the user to the auth page
Expand Down Expand Up @@ -161,6 +164,14 @@ class SocketManager {
});
}

// TODO: this could live as a generic util and not on this class if we ever need it elsewhere
private async unpin() {
// unpin the overlay if there is an error
return invoke("set_pin", {
value: false,
});
}

/**
* Message listener when we get message from discord
* @param payload a JSON object of the parsed message
Expand All @@ -170,6 +181,8 @@ class SocketManager {
// and not have to check the raw dawg string to see if something is wrong
if (typeof event === "string" && (event as string).includes("Connection reset without closing handshake")) {
this.navigate("/error");

await this.unpin();
}

// TODO: does this ever happen?
Expand Down Expand Up @@ -298,6 +311,7 @@ class SocketManager {
}

this.store.pushError(payload.data.message);

// move to the error page
this.navigate("/error");

Expand Down

0 comments on commit 5d70750

Please sign in to comment.