diff --git a/components/apps/Browser/index.tsx b/components/apps/Browser/index.tsx index 48ea14bb..968063e3 100644 --- a/components/apps/Browser/index.tsx +++ b/components/apps/Browser/index.tsx @@ -51,7 +51,7 @@ const Browser: FC = ({ id }) => { processes: { [id]: process }, open, } = useProcesses(); - const { setForegroundId } = useSession(); + const { setForegroundId, updateRecentFiles } = useSession(); const { prependFileToTitle } = useTitle(id); const { initialTitle = "", url = "" } = process || {}; const initialUrl = url || HOME_PAGE; @@ -263,8 +263,13 @@ const Browser: FC = ({ id }) => { fs, decodeURI(pathname), getExtension(pathname), - ({ pid, url: infoUrl }) => - open(pid || "OpenWith", { url: infoUrl }) + ({ pid, url: infoUrl }) => { + open(pid || "OpenWith", { url: infoUrl }); + + if (pid && infoUrl) { + updateRecentFiles(infoUrl, pid); + } + } ); } }); @@ -356,6 +361,7 @@ const Browser: FC = ({ id }) => { readdir, setIcon, stat, + updateRecentFiles, ] ); diff --git a/components/apps/FileExplorer/AddressBar.tsx b/components/apps/FileExplorer/AddressBar.tsx index e10df16d..ad9f1cf9 100644 --- a/components/apps/FileExplorer/AddressBar.tsx +++ b/components/apps/FileExplorer/AddressBar.tsx @@ -10,6 +10,7 @@ import Icon from "styles/common/Icon"; import { DISBALE_AUTO_INPUT_FEATURES, ROOT_NAME } from "utils/constants"; import { getExtension, label } from "utils/functions"; import { getProcessByFileExtension } from "components/system/Files/FileEntry/functions"; +import { useSession } from "contexts/session"; type AddressBarProps = { id: string; @@ -40,6 +41,7 @@ const AddressBar = forwardRef( const displayName = basename(url) || ROOT_NAME; const [addressBar, setAddressBar] = useState(displayName); const { exists, stat, updateFolder } = useFileSystem(); + const { updateRecentFiles } = useSession(); useEffect(() => { if (addressBarRef.current) { @@ -67,11 +69,15 @@ const AddressBar = forwardRef( if (value && (await exists(value))) { if ((await stat(value)).isDirectory()) changeUrl(id, value); else { - open( - getProcessByFileExtension(getExtension(value)) || - "OpenWith", - { url: value } + const openPid = getProcessByFileExtension( + getExtension(value) ); + + open(openPid || "OpenWith", { url: value }); + + if (openPid && value) { + updateRecentFiles(value, openPid); + } } } addressBarRef.current.blur(); diff --git a/components/apps/Terminal/useCommandInterpreter.ts b/components/apps/Terminal/useCommandInterpreter.ts index 45d8ff65..b3d89fd8 100644 --- a/components/apps/Terminal/useCommandInterpreter.ts +++ b/components/apps/Terminal/useCommandInterpreter.ts @@ -1089,6 +1089,7 @@ const useCommandInterpreter = ( case "wsl": case "linux": open("V86", { url: LINUX_IMAGE_PATH }); + updateRecentFiles(LINUX_IMAGE_PATH, "V86"); break; case "xlsx": { const [file, format = "xlsx"] = commandArgs; diff --git a/components/system/Files/FileManager/useFolderContextMenu.ts b/components/system/Files/FileManager/useFolderContextMenu.ts index 4755faff..31508b60 100644 --- a/components/system/Files/FileManager/useFolderContextMenu.ts +++ b/components/system/Files/FileManager/useFolderContextMenu.ts @@ -568,9 +568,7 @@ const useFolderContextMenu = ( } open("MonacoEditor", { url: INDEX_FILE }); - if (INDEX_FILE) { - updateRecentFiles(INDEX_FILE, "MonacoEditor"); - } + updateRecentFiles(INDEX_FILE, "MonacoEditor"); }, label: "View page source", }, diff --git a/hooks/useLinkHandler.ts b/hooks/useLinkHandler.ts index 46595564..61c2b402 100644 --- a/hooks/useLinkHandler.ts +++ b/hooks/useLinkHandler.ts @@ -4,6 +4,7 @@ import { isCorsUrl } from "components/apps/TinyMCE/functions"; import { getProcessByFileExtension } from "components/system/Files/FileEntry/functions"; import { useProcesses } from "contexts/process"; import { haltEvent, isYouTubeUrl, getExtension } from "utils/functions"; +import { useSession } from "contexts/session"; type LinkHandler = ( event: Event, @@ -14,6 +15,7 @@ type LinkHandler = ( export const useLinkHandler = (): LinkHandler => { const { open } = useProcesses(); + const { updateRecentFiles } = useSession(); return useCallback( (event: Event, url: string, pathName: string, title?: string) => { @@ -37,11 +39,17 @@ export const useLinkHandler = (): LinkHandler => { getExtension(pathName) ); - if (defaultProcess) open(defaultProcess, { url: decodeURI(pathName) }); + if (defaultProcess) { + const pathUrl = decodeURI(pathName); + + open(defaultProcess, { url: pathUrl }); + + if (pathUrl) updateRecentFiles(pathUrl, defaultProcess); + } } else { window.open(url, "_blank", "noopener, noreferrer"); } }, - [open] + [open, updateRecentFiles] ); };