@@ -8,6 +8,7 @@ import { useAppMount } from "./app-mount-provider";
88import Checkbox from "./checkbox" ;
99import Flex from "./flex" ;
1010import Stack from "./stack" ;
11+ import EventManager from "src/event/event-manager" ;
1112
1213export default function ReactView ( ) {
1314 const [ folderPath , setFolderPath ] = React . useState < string > ( "" ) ;
@@ -27,6 +28,57 @@ export default function ReactView() {
2728 setOnlyCreatedToday ( settings . filters . onlyCreatedToday ) ;
2829 } , [ ] ) ;
2930
31+ const [ , setRefreshTime ] = React . useState ( 0 ) ;
32+
33+ //TODO optimize
34+ React . useEffect ( ( ) => {
35+ const handleRenameFile = ( oldPath : string , newPath : string ) => {
36+ setRefreshTime ( Date . now ( ) ) ;
37+ } ;
38+
39+ EventManager . getInstance ( ) . on ( "rename-file" , handleRenameFile ) ;
40+ return ( ) => {
41+ EventManager . getInstance ( ) . off ( "rename-file" , handleRenameFile ) ;
42+ } ;
43+ } , [ ] ) ;
44+
45+ //TODO optimize
46+ React . useEffect ( ( ) => {
47+ const handleCreateFile = ( oldPath : string , newPath : string ) => {
48+ setRefreshTime ( Date . now ( ) ) ;
49+ } ;
50+
51+ EventManager . getInstance ( ) . on ( "create-file" , handleCreateFile ) ;
52+ return ( ) => {
53+ EventManager . getInstance ( ) . off ( "create-file" , handleCreateFile ) ;
54+ } ;
55+ } , [ ] ) ;
56+
57+ //TODO optimize
58+ React . useEffect ( ( ) => {
59+ const handleDeleteFile = ( oldPath : string , newPath : string ) => {
60+ setRefreshTime ( Date . now ( ) ) ;
61+ } ;
62+
63+ EventManager . getInstance ( ) . on ( "delete-file" , handleDeleteFile ) ;
64+ return ( ) => {
65+ EventManager . getInstance ( ) . off ( "delete-file" , handleDeleteFile ) ;
66+ } ;
67+ } , [ ] ) ;
68+
69+ //TODO optimize
70+ //TODO should we use handle frontmatter change?
71+ React . useEffect ( ( ) => {
72+ const handleModifyFile = ( oldPath : string , newPath : string ) => {
73+ setRefreshTime ( Date . now ( ) ) ;
74+ } ;
75+
76+ EventManager . getInstance ( ) . on ( "modify-file" , handleModifyFile ) ;
77+ return ( ) => {
78+ EventManager . getInstance ( ) . off ( "modify-file" , handleModifyFile ) ;
79+ } ;
80+ } , [ ] ) ;
81+
3082 React . useEffect ( ( ) => {
3183 onSettingsChange ( {
3284 ...settings ,
0 commit comments