add types for async lib. cleanup commented code

pull/5370/head
Joseph Izang 4 months ago committed by Aniket
parent 2aa12afa95
commit 7e7ada3384
  1. 119
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  2. 3
      package.json
  3. 5
      yarn.lock

@ -78,34 +78,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
setState(workspaceState)
}, [workspaceState])
// useEffect(() => {
// if (treeRef.current) {
// const keyPressHandler = (e: KeyboardEvent) => {
// if (e.shiftKey) {
// setState((prevState) => {
// return { ...prevState, ctrlKey: true }
// })
// }
// }
// const keyUpHandler = (e: KeyboardEvent) => {
// if (!e.shiftKey) {
// setState((prevState) => {
// return { ...prevState, ctrlKey: false }
// })
// }
// }
// const targetDocument = treeRef.current
// targetDocument.addEventListener('keydown', keyPressHandler)
// targetDocument.addEventListener('keyup', keyUpHandler)
// return () => {
// targetDocument.removeEventListener('keydown', keyPressHandler)
// targetDocument.removeEventListener('keyup', keyUpHandler)
// }
// }
// }, [treeRef.current])
useEffect(() => {
const performDeletion = async () => {
const path: string[] = []
@ -135,7 +107,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
const performCut = async () => {
console.log('check feTarget', feTarget)
if (feTarget) {
if (feTarget.length > 0 && feTarget[0].key.length > 0) {
handleMultiCopies(feTarget)
@ -148,12 +119,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
const performPaste = async () => {
if (feTarget.length > 0 && feTarget[0]?.key.length >= 0) {
console.log('cut-mode has been activated', cutActivated)
if (cutActivated) {
if (state.copyElement.length > 1) {
console.log('more than one item is ready to be cut')
const promisesToKeep = state.copyElement.filter(x => x).map(async (item) => {
console.log('cutting files now')
if (item.type === 'file') {
props.dispatchMoveFile(item.key, feTarget[0].key)
} else {
@ -249,57 +217,60 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const CopyComboHandler = async (eve: KeyboardEvent) => {
if (eve.metaKey && eve.code === 'KeyC' && (window as any).navigator.userAgentData.platform === 'macOS') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCopy()
console.log('copy performed on a mac')
return
let CopyComboHandler: (eve: KeyboardEvent) => Promise<void>
let CutHandler: (eve: KeyboardEvent) => Promise<void>
let pasteHandler: (eve: KeyboardEvent) => Promise<void>
let pcCopyHandler: (eve: KeyboardEvent) => Promise<void>
let pcCutHandler: (eve: KeyboardEvent) => Promise<void>
let pcPasteHandler: (eve: KeyboardEvent) => Promise<void>
if ((window as any).navigator.userAgentData.platform === 'macOS') {
CopyComboHandler = async (eve: KeyboardEvent) => {
if (eve.metaKey && eve.code === 'KeyC') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCopy()
return
}
}
}
const pcCopyHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && (eve.key === 'c' || eve.key === 'C') && (window as any).navigator.userAgentData.platform !== 'macOS') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCopy()
console.log('copy perfomed on a pc')
return
CutHandler = async (eve: KeyboardEvent) => {
if (eve.metaKey && eve.code === 'KeyX') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCut()
return
}
}
}
const pcCutHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && eve.code === 'KeyX' && (window as any).navigator.userAgentData.platform !== 'macOS') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCut()
console.log('cut performed on a pc')
return
pasteHandler = async (eve: KeyboardEvent) => {
if (eve.metaKey && eve.code === 'KeyV') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'metaVToPaste', 'PasteCopiedContent'])
performPaste()
return
}
}
}
const CutHandler = async (eve: KeyboardEvent) => {
if (eve.metaKey && eve.code === 'KeyX' && (window as any).navigator.userAgentData.platform === 'macOS') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCut()
console.log('Cut performed on mac')
return
} else {
pcCopyHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && (eve.key === 'c' || eve.key === 'C')) {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCopy()
return
}
}
}
const pasteHandler = async (eve: KeyboardEvent) => {
if (eve.metaKey && eve.code === 'KeyV' && (window as any).navigator.userAgentData.platform === 'macOS') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'metaVToPaste', 'PasteCopiedContent'])
performPaste()
console.log('paste performed on mac')
return
pcCutHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && eve.code === 'KeyX') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCut()
return
}
}
}
const pcPasteHandler = async (eve: KeyboardEvent) => {
if (eve.key === 'Control' && eve.code === 'KeyV' && (window as any).navigator.userAgentData.platform !== 'macOS') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'ctrlVToPaste', 'PasteCopiedContent'])
performPaste()
console.log('paste performed on pc')
return
pcPasteHandler = async (eve: KeyboardEvent) => {
if (eve.key === 'Control' && eve.code === 'KeyV') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'ctrlVToPaste', 'PasteCopiedContent'])
performPaste()
return
}
}
}

@ -98,10 +98,10 @@
"@ethereumjs/util": "9.0.3",
"@ethereumjs/vm": "8.0.0",
"@ethersphere/bee-js": "^3.2.0",
"@floating-ui/react": "^0.26.15",
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@floating-ui/react": "^0.26.15",
"@gradio/client": "^0.10.1",
"@isomorphic-git/lightning-fs": "^4.4.1",
"@metamask/eth-sig-util": "^7.0.2",
@ -252,6 +252,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@svgr/webpack": "^6.5.1",
"@testing-library/react": "13.4.0",
"@types/async": "^3.2.24",
"@types/axios": "^0.14.0",
"@types/chai": "^4.3.3",
"@types/express-ws": "^3.0.1",

@ -7201,6 +7201,11 @@
resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc"
integrity sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==
"@types/async@^3.2.24":
version "3.2.24"
resolved "https://registry.yarnpkg.com/@types/async/-/async-3.2.24.tgz#3a96351047575bbcf2340541b2d955a35339608f"
integrity sha512-8iHVLHsCCOBKjCF2KwFe0p9Z3rfM9mL+sSP8btyR5vTjJRAqpBYD28/ZLgXPf0pjG1VxOvtCV/BgXkQbpSe8Hw==
"@types/aws-lambda@^8.10.83":
version "8.10.130"
resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.130.tgz#d4a44201f0e47c8320a5868d845ad654f3b4adc2"

Loading…
Cancel
Save