fix useEffect dependency issue. Fix platform specificity

pull/5062/head
Joseph Izang 4 months ago committed by Aniket
parent 1e2b40a21c
commit c4c1b764a8
  1. 18
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  2. 2
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  3. 1
      libs/remix-ui/workspace/src/lib/types/index.ts

@ -34,7 +34,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
deletePath,
uploadFile,
uploadFolder,
fileState
fileState,
canPaste
} = props
const [state, setState] = useState<WorkSpaceState>(workspaceState)
// const [isPending, startTransition] = useTransition();
@ -97,6 +98,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
const targetDocument = treeRef.current
console.log('what does the ref contain?', { treeRef })
targetDocument.addEventListener('keydown', keyPressHandler)
targetDocument.addEventListener('keyup', keyUpHandler)
return () => {
@ -171,6 +174,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
props.editModeOn(feTarget[0].key, feTarget[0].type, false)
}
if (treeRef.current) {
const F2KeyPressHandler = async (eve: KeyboardEvent) => {
if (eve.key === 'F2' ) {
@ -247,6 +251,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const focus = state.copyElement
console.log('copied', focus)
if (treeRef.current) {
const targetDocument = treeRef.current
let CopyComboHandler: (eve: KeyboardEvent) => Promise<void>
@ -280,10 +287,11 @@ export const FileExplorer = (props: FileExplorerProps) => {
return
}
}
} else {
}
if ((window as any).navigator.platform === 'Linux x86_64' || (window as any).navigator.platform === 'Win32') {
pcCopyHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && (eve.key === 'c' || eve.key === 'C')) {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
feWindow._paq.push(['trackEvent', 'fileExplorer', 'CtrlCToCopy', 'CopyPath'])
await performCopy()
return
}
@ -291,7 +299,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
pcCutHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && eve.code === 'KeyX') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
feWindow._paq.push(['trackEvent', 'fileExplorer', 'CtrlXToCut', 'CutPath'])
await performCut()
return
}
@ -322,7 +330,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
targetDocument?.removeEventListener('keydown', pcCopyHandler)
}
}
}, [treeRef.current, feTarget])
}, [treeRef.current, feTarget, canPaste, state.copyElement.length])
const hasReservedKeyword = (content: string): boolean => {
if (state.reservedKeywords.findIndex((value) => content.startsWith(value)) !== -1) return true

@ -1071,6 +1071,7 @@ export function Workspace() {
renamePath={editModeOn}
importFromIpfs={importFromUrl}
importFromHttps={importFromUrl}
canPaste={canPaste}
/>
)}
@ -1088,6 +1089,7 @@ export function Workspace() {
files={global.fs.localhost.files}
flatTree={global.fs.localhost.flatTree}
fileState={[]}
canPaste={canPaste}
workspaceState={state}
expandPath={global.fs.localhost.expandPath}
focusEdit={global.fs.focusEdit}

@ -101,6 +101,7 @@ export interface FilePanelType extends ViewPlugin {
export interface FileExplorerProps {
name: string,
menuItems?: string[],
canPaste: boolean
contextMenuItems: MenuItems,
removedContextMenuItems: MenuItems,
files: { [x: string]: Record<string, FileType> },

Loading…
Cancel
Save