mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Fix some props issues
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
// hooks/useFileNavigation.js
|
||||
import { useState, useCallback } from 'react';
|
||||
import { useToasts } from '@geist-ui/core';
|
||||
import { lookupFileByName } from '../services/api';
|
||||
import { DEFAULT_FILE } from '../utils/constants'; // Assuming you have this constant defined
|
||||
import { DEFAULT_FILE } from '../utils/constants';
|
||||
|
||||
export const useFileNavigation = () => {
|
||||
const { setToast } = useToasts();
|
||||
@@ -10,6 +9,11 @@ export const useFileNavigation = () => {
|
||||
const [selectedFile, setSelectedFile] = useState(DEFAULT_FILE.path);
|
||||
const [isNewFile, setIsNewFile] = useState(true);
|
||||
|
||||
const handleFileSelect = useCallback((filePath) => {
|
||||
setSelectedFile(filePath);
|
||||
setIsNewFile(filePath === DEFAULT_FILE.path);
|
||||
}, []);
|
||||
|
||||
const handleLinkClick = useCallback(
|
||||
async (filename) => {
|
||||
try {
|
||||
@@ -27,13 +31,8 @@ export const useFileNavigation = () => {
|
||||
});
|
||||
}
|
||||
},
|
||||
[handleFileSelect]
|
||||
[handleFileSelect, setToast]
|
||||
);
|
||||
|
||||
const handleFileSelect = useCallback(async (filePath) => {
|
||||
setSelectedFile(filePath);
|
||||
setIsNewFile(filePath === DEFAULT_FILE.path);
|
||||
}, []);
|
||||
|
||||
return { handleLinkClick, selectedFile, isNewFile, handleFileSelect };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user