Skip to content

Canary rendering flow change #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"type": "module",
"scripts": {
"start": "tauri dev",
"start:canary": "tauri dev --config src-tauri/tauri.conf.canary.json",
"dev": "vite",
"build": "tsc && vite build",
"build:canary": "cargo tauri build --config 'src-tauri/tauri.conf.canary.json'",
"build:canary": " tauri build --config 'src-tauri/tauri.conf.canary.json'",
"lint": "eslint",
"clean": "rm -rf dist .turbo node_modules",
"check:format": "prettier --check 'src/**/*.{ts,js,tsx,jsx}'",
Expand Down
Binary file added apps/desktop/public/img/32x32-canary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions apps/desktop/src/components/nav-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import {
ChevronsRightLeft,
type LucideIcon,
} from "lucide-react";

import { usePlatformInfo } from "@/hooks/use-platform-info";
import React from "react";
import { invoke } from "@tauri-apps/api";
import overlayedConfig, { type DirectionLR } from "../config";
import { useAppStore } from "../store";
import { useState } from "react";

const mapping = {
left: 0,
center: 1,
Expand Down Expand Up @@ -66,6 +65,7 @@ export const NavBar = ({
const showUpdateButton = location.pathname !== "/settings" && isUpdateAvailable;

const routesToShowOn = ["/channel", "/error", "/"];
const { canary } = usePlatformInfo();
if (!routesToShowOn.includes(location.pathname)) return null;

return (
Expand All @@ -75,7 +75,13 @@ export const NavBar = ({
>
<div data-tauri-drag-region className="flex justify-between">
<div className="flex items-center">
<img src="/img/32x32.png" alt="logo" data-tauri-drag-region className="w-8 h-8 mr-2" />
<img
src={canary ? "/img/32x32-canary.png " : "/img/32x32.png"}
alt="logo"
data-tauri-drag-region
className="w-8 h-8 mr-2"
/>

{location.pathname === "/channel" ? (
<div data-tauri-drag-region className="hidden md:inline">
{currentChannel?.name}
Expand All @@ -86,7 +92,7 @@ export const NavBar = ({
</div>
{location.pathname !== "/settings" && (
<div className="hidden gap-4 md:flex">
{showUpdateButton && (
{!canary && showUpdateButton && (
<button>
<Download
className="text-green-500"
Expand Down
24 changes: 17 additions & 7 deletions apps/desktop/src/hooks/use-platform-info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";

import { getTauriVersion, getVersion } from "@tauri-apps/api/app";
import { getName, getTauriVersion, getVersion } from "@tauri-apps/api/app";
import { appConfigDir } from "@tauri-apps/api/path";
import { platform as getPlatform, version as getKernalVersion, arch as getArch } from "@tauri-apps/api/os";

Expand All @@ -11,30 +11,40 @@ export const usePlatformInfo = () => {
os: "",
kernalVersion: "",
arch: "",
name: "",
canary: false,
configDir: "",
});

useEffect(() => {
const allPromises = [getTauriVersion(), getVersion(), getPlatform(), getKernalVersion(), getArch(), appConfigDir()];
const allPromises = [
getTauriVersion(),
getVersion(),
getPlatform(),
getKernalVersion(),
getArch(),
appConfigDir(),
getName(),
];

// get all the dataz
Promise.allSettled(allPromises).then(results => {
const [tauriVersion = "", appVersion = "", os = "", kernalVersion = "", arch = "", configDir = ""] = results.map(
result => {
const [tauriVersion = "", appVersion = "", os = "", kernalVersion = "", arch = "", configDir = "", name = ""] =
results.map(result => {
if (result.status === "fulfilled") {
return result.value;
}
return "";
}
);

});
setPlatformInfo({
tauriVersion,
appVersion,
os,
kernalVersion,
arch,
configDir,
name,
canary: name.includes("Canary"),
});
});
}, []);
Expand Down
11 changes: 9 additions & 2 deletions apps/desktop/src/views/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Account } from "./account";
import { JoinHistory } from "./join-history";
import { useState } from "react";
import { usePlatformInfo } from "@/hooks/use-platform-info";

export const SettingsView = ({
update,
}: {
update: { isAvailable: boolean; status: UpdateStatus | null; error: string };
}) => {
const { canary } = usePlatformInfo();
const [currentTab, setCurrentTab] = useState("account");
return (
<div className="bg-zinc-900 w-[calc(100vw)] h-full">
Expand All @@ -23,7 +25,12 @@ export const SettingsView = ({
<TabsTrigger value="account">General</TabsTrigger>
<TabsTrigger value="join-history">Join History</TabsTrigger>
</TabsList>
{update.isAvailable && <Updater update={update} />}
<div className="py-2 h-[48px] bg-orange-800">
<div className="!text-white text-lg font-bold cursor-pointer flex gap-2 items-center justify-center">
<p>Canary build careful...</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ill enhance this later to say something more reasonable!

</div>
</div>
{canary && update.isAvailable && <Updater update={update} />}
<div className="p-4 pt-0">
<TabsContent tabIndex={-1} value="account">
<Account />
Expand All @@ -34,7 +41,7 @@ export const SettingsView = ({
</div>
</TabsContent>
</div>
<div className="h-10 pl-4 absolute bottom-0 w-full bg-zinc-800 text-gray-400 flex items-center">
<div className="absolute bottom-0 flex items-center w-full h-10 pl-4 text-gray-400 bg-zinc-800">
<p>
Found a bug? Please report them on the{" "}
<a className="text-blue-400" target="_blank" rel="noreferrer" href="https://github.com/Hacksore/overlayed">
Expand Down