Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Remove tray timer (Will be implemented better in the future)

Ilyabcfe67bce4b4
diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml
index e09726d4a..ba1124c65 100644
--- a/apps/desktop/src-tauri/Cargo.toml
+++ b/apps/desktop/src-tauri/Cargo.toml
@@ -19,9 +19,12 @@ tauri = { version = "=2.0.0-rc.0", features = [
"tray-icon",
"image-png",
] }
+tauri-plugin-fs = "2.0.0-rc.0"
+tauri-plugin-os = "2.0.0-rc.0"
tauri-plugin-shell = "2.0.0-rc"
tauri-plugin-global-shortcut = "2.0.0-rc"
tauri-plugin-oauth = { git = "https://github.com/FabianLars/tauri-plugin-oauth", branch = "v2" }
+tauri-plugin-decorum = "1.0.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
@@ -57,9 +60,6 @@ specta = "=2.0.0-rc.19"
tauri-specta = { version = "=2.0.0-rc.14", features = ["derive", "typescript"] }
specta-typescript = "0.0.6"
dirs = "5.0.1"
-tauri-plugin-decorum = "1.0.0"
-tauri-plugin-fs = "2.0.0-rc.0"
-tauri-plugin-os = "2.0.0-rc.0"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.9", features = [
diff --git a/apps/desktop/src/app/page.tsx b/apps/desktop/src/app/page.tsx
index 0dd36d713..039da1cf5 100644
--- a/apps/desktop/src/app/page.tsx
+++ b/apps/desktop/src/app/page.tsx
@@ -6,7 +6,7 @@ import { Recorder } from "@/components/windows/inner/Recorder";
import { WindowActions } from "@/components/WindowActions";
import { Permissions } from "@/components/windows/Permissions";
import { LogoSpinner } from "@cap/ui";
-import { getPermissions, toMonospaceUnicodeString } from "@/utils/helpers";
+import { getPermissions } from "@/utils/helpers";
import { initializeCameraWindow } from "@/utils/recording/utils";
import { getVersion } from "@tauri-apps/api/app";
import toast from "react-hot-toast";
diff --git a/apps/desktop/src/components/windows/inner/Recorder.tsx b/apps/desktop/src/components/windows/inner/Recorder.tsx
index 84c799729..a9cb4aea8 100644
--- a/apps/desktop/src/components/windows/inner/Recorder.tsx
+++ b/apps/desktop/src/components/windows/inner/Recorder.tsx
@@ -27,12 +27,11 @@ import {
getUserId,
isUserPro,
} from "@cap/utils";
-import { openLinkInBrowser, toMonospaceUnicodeString } from "@/utils/helpers";
+import { openLinkInBrowser } from "@/utils/helpers";
import { commands } from "@/utils/commands";
import toast, { Toaster } from "react-hot-toast";
import { authFetch } from "@/utils/auth/helpers";
-import { setTrayStopIcon, setTrayTitle } from "@/utils/tray";
-import { type as osType } from "@tauri-apps/plugin-os";
+import { setTrayStopIcon } from "@/utils/tray";
declare global {
interface Window {
@@ -308,7 +307,6 @@ export const Recorder = () => {
useEffect(() => {
let intervalId: NodeJS.Timeout;
- let shouldShowTimer = osType() !== "windows";
if (isRecording && !startingRecording) {
const startTime = Date.now();
@@ -319,19 +317,11 @@ export const Recorder = () => {
const formattedSeconds =
seconds % 60 < 10 ? `0${seconds % 60}` : seconds % 60;
setRecordingTime(`${minutes}:${formattedSeconds}`);
-
- // TODO: Maybe move to backend.
- if (shouldShowTimer) {
- setTrayTitle(
- toMonospaceUnicodeString(` ${minutes}:${formattedSeconds}`)
- );
- }
}, 1000);
}
return () => {
clearInterval(intervalId);
setRecordingTime("00:00");
- if (shouldShowTimer) setTrayTitle(null);
};
}, [isRecording, startingRecording]);
diff --git a/apps/desktop/src/utils/helpers.ts b/apps/desktop/src/utils/helpers.ts
index f4e004f99..966c47322 100644
--- a/apps/desktop/src/utils/helpers.ts
+++ b/apps/desktop/src/utils/helpers.ts
@@ -66,29 +66,3 @@ export const savePermissions = async (permission: string, value: boolean) => {
console.error("Failed to save permissions:", error);
}
};
-
-/**
- * Credits:
- * https://github.com/davidkonrad/toUnicodeVariant/blob/master/toUnicodeVariant.js
- */
-const offsets = {
- m: [0x1d670, 0x1d7f6],
-};
-
-const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-const numbers = "0123456789";
-
-export const toMonospaceUnicodeString = (str: string) => {
- let result = "";
- for (let c of str) {
- let index: number | null;
- if ((index = chars.indexOf(c)) > -1) {
- result += String.fromCodePoint(index + offsets.m[0]);
- } else if ((index = numbers.indexOf(c)) > -1) {
- result += String.fromCodePoint(index + offsets.m[1]);
- } else {
- result += c;
- }
- }
- return result;
-};
diff --git a/apps/desktop/src/utils/tray.ts b/apps/desktop/src/utils/tray.ts
index fe181ae8a..6666006ce 100644
--- a/apps/desktop/src/utils/tray.ts
+++ b/apps/desktop/src/utils/tray.ts
@@ -9,7 +9,6 @@ import { TrayIcon } from "@tauri-apps/api/tray";
import { emit } from "@tauri-apps/api/event";
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
import { Device, DeviceKind } from "./recording/MediaDeviceContext";
-import { toMonospaceUnicodeString } from "./helpers";
const TRAY_ID = "cap_main";
const TRAY_ICON_DEFAULT = "icons/tray-default-icon.png";