upd: announcement

Deskripsi:
- pagination scrooll load

No Issues
This commit is contained in:
amel
2024-09-19 11:37:41 +08:00
parent 4026c58e8f
commit f8ca866cc6
6 changed files with 116 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
import { hookstate } from "@hookstate/core"
import { IGlobalTema } from './type_global';
import { RefObject } from "react";
export const pwd_key_config = "fchgvjknlmdfnbvghhujlaknsdvjbhknlkmsdbdyu567t8y9u30r4587638y9uipkoeghjvuyi89ipkoefmnrjbhtiu4or9ipkoemnjfbhjiuoijdklnjhbviufojkejnshbiuojijknehgruyu"
export const globalRole = hookstate<string>('')
@@ -24,4 +25,6 @@ export const TEMA = hookstate<IGlobalTema>({
export const globalNotifPage = hookstate({
load: false,
category: ''
})
})
export const currentScroll = hookstate<RefObject<HTMLDivElement> | null>(null);

View File

@@ -0,0 +1,38 @@
"use client";
import { useHookstate } from "@hookstate/core";
import { useEffect, useRef } from "react";
import { Box } from "@mantine/core";
import { currentScroll } from "../bin/val_global";
export function ScrollProvider({ children }: { children: React.ReactNode }) {
const containerRef = useRef<HTMLDivElement>(null);
const { set } = useHookstate(currentScroll);
useEffect(() => {
if (window) {
const handleScroll = () => {
if (containerRef.current) {
set(containerRef);
}
};
const container = containerRef.current;
container?.addEventListener("scroll", handleScroll);
return () => {
container?.removeEventListener("scroll", handleScroll);
};
}
}, [containerRef, set]);
return (
<Box
h={"100vh"}
style={{ overflow: "auto", position: "relative" }}
ref={containerRef}
>
{children}
</Box>
);
}

View File

@@ -1,6 +1,6 @@
import MqttLoad from "./bin/mqtt_load";
import prisma from "./bin/prisma";
import { DIR, globalNotifPage, globalRole, pwd_key_config, TEMA } from "./bin/val_global";
import { currentScroll, DIR, globalNotifPage, globalRole, pwd_key_config, TEMA } from "./bin/val_global";
import SkeletonAvatar from "./components/skeleton_avatar";
import SkeletonDetailDiscussionComment from "./components/skeleton_detail_discussion_comment";
import SkeletonDetailDiscussionMember from "./components/skeleton_detail_discussion_member";
@@ -24,6 +24,7 @@ import ReloadButtonTop from "./components/reload_button_top";
import ViewFilter from "./view/view_filter";
import mtqq_client from "./bin/mqtt_client"
import NotificationCustome from "./components/notification_custome";
import { ScrollProvider } from "./components/scroll_provider";
export { WARNA };
export { LayoutLogin };
@@ -55,3 +56,5 @@ export { globalNotifPage }
export { SkeletonAvatar }
export { ReloadButtonTop }
export { NotificationCustome }
export { ScrollProvider }
export { currentScroll }