(feat): tauri -> electron desktop app migration #9
3 changed files with 47 additions and 4 deletions
(fix): chat message measurement
(qol): update todos
commit
d297282320
|
|
@ -11,4 +11,3 @@
|
||||||
- Desktop-App screenshares
|
- Desktop-App screenshares
|
||||||
- Context menus
|
- Context menus
|
||||||
- Popout Window
|
- Popout Window
|
||||||
- If micGated=true & isSpeaking=false for 5 seconds show banner with mic detection
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import Message from "./components/message";
|
||||||
|
|
||||||
import { PAGE_SIZE } from "./values";
|
import { PAGE_SIZE } from "./values";
|
||||||
import { useIsMobile } from "@tensamin/ui";
|
import { useIsMobile } from "@tensamin/ui";
|
||||||
|
import { Loader2 } from "lucide-react";
|
||||||
|
|
||||||
function getDistanceFromBottom(element: HTMLDivElement) {
|
function getDistanceFromBottom(element: HTMLDivElement) {
|
||||||
return element.scrollHeight - (element.scrollTop + element.clientHeight);
|
return element.scrollHeight - (element.scrollTop + element.clientHeight);
|
||||||
|
|
@ -360,9 +361,38 @@ export default function Screen() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rafId: number;
|
||||||
|
let stableFrames = 0;
|
||||||
|
let lastScrollHeight = 0;
|
||||||
|
|
||||||
|
const settleToBottom = () => {
|
||||||
|
if (!scrollRef.current || hasScrolledToBottomInitially) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
||||||
|
const currentScrollHeight = scrollRef.current.scrollHeight;
|
||||||
|
|
||||||
|
if (currentScrollHeight === lastScrollHeight) {
|
||||||
|
stableFrames++;
|
||||||
|
} else {
|
||||||
|
stableFrames = 0;
|
||||||
|
lastScrollHeight = currentScrollHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stableFrames >= 2) {
|
||||||
isAtBottomRef.current = true;
|
isAtBottomRef.current = true;
|
||||||
setHasScrolledToBottomInitially(true);
|
setHasScrolledToBottomInitially(true);
|
||||||
|
} else {
|
||||||
|
rafId = requestAnimationFrame(settleToBottom);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
settleToBottom();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelAnimationFrame(rafId);
|
||||||
|
};
|
||||||
}, [hasScrolledToBottomInitially, virtualRowCount]);
|
}, [hasScrolledToBottomInitially, virtualRowCount]);
|
||||||
|
|
||||||
React.useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
|
|
@ -442,6 +472,19 @@ export default function Screen() {
|
||||||
}}
|
}}
|
||||||
onScroll={handleContainerScroll}
|
onScroll={handleContainerScroll}
|
||||||
>
|
>
|
||||||
|
{messagesQuery.isPending && (
|
||||||
|
<div className="flex items-center justify-center pt-10">
|
||||||
|
<p className="text-foreground/45 flex gap-1 items-center justify-center">
|
||||||
|
<Loader2 size={18} className="animate-spin" />
|
||||||
|
Loading...
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{messagesQuery.isFetchingNextPage && (
|
||||||
|
<div className="flex items-center justify-center pt-3 pb-1">
|
||||||
|
<Loader2 size={16} className="animate-spin text-foreground/45" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div
|
<div
|
||||||
className="relative w-full"
|
className="relative w-full"
|
||||||
style={{
|
style={{
|
||||||
|
|
|
||||||
1
packages/chat/todo.md
Normal file
1
packages/chat/todo.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
- Add context menu to messages
|
||||||
Loading…
Reference in a new issue