mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Migrate to remark
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { notifications } from '@mantine/notifications';
|
||||
import { lookupFileByName } from '../services/api';
|
||||
import { DEFAULT_FILE } from '../utils/constants';
|
||||
import { useWorkspace } from '../contexts/WorkspaceContext';
|
||||
import { useLastOpenedFile } from './useLastOpenedFile';
|
||||
@@ -24,33 +22,6 @@ export const useFileNavigation = () => {
|
||||
[saveLastOpenedFile]
|
||||
);
|
||||
|
||||
const handleLinkClick = useCallback(
|
||||
async (filename) => {
|
||||
if (!currentWorkspace) return;
|
||||
|
||||
try {
|
||||
const filePaths = await lookupFileByName(currentWorkspace.id, filename);
|
||||
if (filePaths.length >= 1) {
|
||||
handleFileSelect(filePaths[0]);
|
||||
} else {
|
||||
notifications.show({
|
||||
title: 'File Not Found',
|
||||
message: `File "${filename}" not found`,
|
||||
color: 'red',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error looking up file:', error);
|
||||
notifications.show({
|
||||
title: 'Error',
|
||||
message: 'Failed to lookup file.',
|
||||
color: 'red',
|
||||
});
|
||||
}
|
||||
},
|
||||
[currentWorkspace, handleFileSelect]
|
||||
);
|
||||
|
||||
// Load last opened file when workspace changes
|
||||
useEffect(() => {
|
||||
const initializeFile = async () => {
|
||||
@@ -65,5 +36,5 @@ export const useFileNavigation = () => {
|
||||
initializeFile();
|
||||
}, [currentWorkspace, loadLastOpenedFile, handleFileSelect]);
|
||||
|
||||
return { handleLinkClick, selectedFile, isNewFile, handleFileSelect };
|
||||
return { selectedFile, isNewFile, handleFileSelect };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user