-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
169 additions
and
81 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { LogicalSize, appWindow } from "@tauri-apps/api/window"; | ||
import { useEffect, useRef } from "react"; | ||
|
||
export const useSetWindowSize = ({ | ||
width, | ||
height, | ||
}: { | ||
width: number; | ||
height: number; | ||
}) => { | ||
const lastSizeRef = useRef<LogicalSize | null>(null); | ||
|
||
useEffect(() => { | ||
appWindow.outerSize().then((size) => { | ||
lastSizeRef.current = size; | ||
|
||
// set the new | ||
appWindow.setSize(new LogicalSize(width, height)); | ||
}); | ||
|
||
// on unmount save the last size | ||
return () => { | ||
if (lastSizeRef.current) { | ||
appWindow.setSize(lastSizeRef.current); | ||
} | ||
}; | ||
}, []); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
// write a window rezise hook | ||
export const useWindowResize = () => { | ||
const [windowSize, setWindowSize] = useState({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}); | ||
|
||
useEffect(() => { | ||
const handleResize = () => { | ||
setWindowSize({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}); | ||
}; | ||
window.addEventListener("resize", handleResize); | ||
return () => window.removeEventListener("resize", handleResize); | ||
}, []); | ||
|
||
return windowSize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,49 @@ | ||
import { useNavigate } from "react-router-dom"; | ||
import { useSocket } from "../rpc/manager"; | ||
import { useAppStore } from "../store"; | ||
import { useEffect } from "react"; | ||
import { useSetWindowSize } from "../use-set-size"; | ||
import { Button } from "../components/ui/button"; | ||
import { Link } from "react-router-dom"; | ||
|
||
export const Main = () => { | ||
const socket = useSocket(); | ||
const navigate = useNavigate(); | ||
useSocket(); | ||
useSetWindowSize({ width: 400, height: 600 }); | ||
const { resetErrors } = useAppStore(); | ||
|
||
useEffect(() => { | ||
resetErrors(); | ||
}, []); | ||
|
||
return ( | ||
<div className="h-screen p-2 bg-zinc-800"> | ||
{!socket?.isConnected ? ( | ||
<div className="flex items-center justify-center h-full"> | ||
<div className="animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-white"></div> | ||
</div> | ||
) : ( | ||
<> | ||
<div className="pt-1 mb-3 font-bold text-2xl text-center"> | ||
<p>Authorize Discord</p> | ||
</div> | ||
<div className="pt-1 mb-3 font-bold text-2xl text-center"> | ||
<p>Authorize Discord</p> | ||
<ul className="text-sm text-center"> | ||
<li className="text-zinc-400"> | ||
<p> | ||
This app is not affiliated with Discord. Discord is a trademark of | ||
Discord Inc. | ||
</p> | ||
</li> | ||
</ul> | ||
<ul className="flex flex-col gap-4 p-4 mt-6 text-2xl text-left"> | ||
<li> | ||
<p className="leading-8">1. Discord should have opened a popup</p> | ||
</li> | ||
<li> | ||
<p className="leading-8">2. Click "Authorize" within discord</p> | ||
</li> | ||
<li> | ||
<p className="leading-8">3. Join a voice channel</p> | ||
</li> | ||
</ul> | ||
|
||
<img src="/img/login.png" alt="login" className="w-full" /> | ||
<div className="pt-8 text-2xl flex items-center flex-col justify-center"> | ||
<p>Request Prompt again</p> | ||
<Button | ||
onClick={() => { | ||
socket?.init(navigate); | ||
}} | ||
className="bg-blue-800 p-2 rounded-md" | ||
> | ||
Authorize Discord | ||
</Button> | ||
</div> | ||
</> | ||
)} | ||
<div className="pt-8 text-2xl flex items-center justify-center"> | ||
<Button> | ||
<Link to="/">Try Again</Link> | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |