mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
* Upgrade @typescript-eslint dependencies from v6.21.0 to v8.33.0 - Updated @typescript-eslint/eslint-plugin from ^6.21.0 to ^8.33.0 - Updated @typescript-eslint/parser from ^6.21.0 to ^8.33.0 - Tested linting functionality to ensure compatibility - This brings the latest TypeScript ESLint features and bug fixes * lint * tsc --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
34 lines
745 B
TypeScript
34 lines
745 B
TypeScript
import { useRef, useEffect } from "react";
|
|
import Document from "~/models/Document";
|
|
|
|
const MARK_AS_VIEWED_AFTER = 3 * 1000;
|
|
type Props = {
|
|
document: Document;
|
|
children?: JSX.Element;
|
|
};
|
|
|
|
function MarkAsViewed(props: Props) {
|
|
const { document, children } = props;
|
|
const viewTimeout = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
|
|
useEffect(() => {
|
|
viewTimeout.current = setTimeout(async () => {
|
|
const view = await document.view();
|
|
|
|
if (view) {
|
|
document.updateLastViewed(view);
|
|
}
|
|
}, MARK_AS_VIEWED_AFTER);
|
|
|
|
return () => {
|
|
if (viewTimeout.current) {
|
|
clearTimeout(viewTimeout.current);
|
|
}
|
|
};
|
|
}, [document]);
|
|
|
|
return children || null;
|
|
}
|
|
|
|
export default MarkAsViewed;
|