fix: child webview is not reposition after scroll

This commit is contained in:
reya
2024-07-19 13:10:29 +07:00
parent f3db010c74
commit 07ce253f5b
17 changed files with 2163 additions and 2161 deletions

View File

@@ -3,7 +3,7 @@ import type { LumeColumn } from "@lume/types";
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { Menu, MenuItem, PredefinedMenuItem } from "@tauri-apps/api/menu";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { memo, useCallback, useEffect, useRef, useState } from "react";
type WindowEvent = {
@@ -106,7 +106,7 @@ function Header({
const [isChanged, setIsChanged] = useState(false);
const saveNewTitle = async () => {
const mainWindow = getCurrentWebviewWindow();
const mainWindow = getCurrentWindow();
await mainWindow.emit("columns", { type: "set_title", label, title });
// update search params
@@ -135,7 +135,7 @@ function Header({
MenuItem.new({
text: "Move left",
action: async () => {
await getCurrentWebviewWindow().emit("columns", {
await getCurrentWindow().emit("columns", {
type: "move",
label,
direction: "left",
@@ -145,7 +145,7 @@ function Header({
MenuItem.new({
text: "Move right",
action: async () => {
await getCurrentWebviewWindow().emit("columns", {
await getCurrentWindow().emit("columns", {
type: "move",
label,
direction: "right",
@@ -156,7 +156,7 @@ function Header({
MenuItem.new({
text: "Close",
action: async () => {
await getCurrentWebviewWindow().emit("columns", {
await getCurrentWindow().emit("columns", {
type: "remove",
label,
});

View File

@@ -30,11 +30,11 @@ function Screen() {
});
const scrollPrev = useCallback(() => {
if (emblaApi) emblaApi.scrollPrev(true);
if (emblaApi) emblaApi.scrollPrev();
}, [emblaApi]);
const scrollNext = useCallback(() => {
if (emblaApi) emblaApi.scrollNext(true);
if (emblaApi) emblaApi.scrollNext();
}, [emblaApi]);
const emitScrollEvent = useCallback(() => {
@@ -101,10 +101,10 @@ function Screen() {
switch (event.code) {
case "ArrowLeft":
if (emblaApi) emblaApi.scrollPrev(true);
if (emblaApi) emblaApi.scrollPrev();
break;
case "ArrowRight":
if (emblaApi) emblaApi.scrollNext(true);
if (emblaApi) emblaApi.scrollNext();
break;
default:
break;

View File

@@ -11,7 +11,6 @@ interface RouterContext {
export const Route = createRootRouteWithContext<RouterContext>()({
component: () => <Outlet />,
pendingComponent: Pending,
wrapInSuspense: true,
});
function Pending() {

View File

@@ -21,6 +21,9 @@ import { type ReactNode, useCallback, useEffect, useRef } from "react";
import { Virtualizer } from "virtua";
export const Route = createFileRoute("/panel/$account")({
beforeLoad: async ({ context }) => {
console.log(context);
},
component: Screen,
});
@@ -30,6 +33,7 @@ function Screen() {
const { isLoading, data } = useQuery({
queryKey: ["notification", account],
queryFn: async () => {
console.log(queryClient);
const events = await NostrQuery.getNotifications();
return events;
},