add types for async lib. cleanup commented code

pull/5062/head
Joseph Izang 4 months ago committed by Aniket
parent 73c485e4ea
commit 775630b76e
  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) setState(workspaceState)
}, [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(() => { useEffect(() => {
const performDeletion = async () => { const performDeletion = async () => {
const path: string[] = [] const path: string[] = []
@ -135,7 +107,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
} }
const performCut = async () => { const performCut = async () => {
console.log('check feTarget', feTarget)
if (feTarget) { if (feTarget) {
if (feTarget.length > 0 && feTarget[0].key.length > 0) { if (feTarget.length > 0 && feTarget[0].key.length > 0) {
handleMultiCopies(feTarget) handleMultiCopies(feTarget)
@ -148,12 +119,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
const performPaste = async () => { const performPaste = async () => {
if (feTarget.length > 0 && feTarget[0]?.key.length >= 0) { if (feTarget.length > 0 && feTarget[0]?.key.length >= 0) {
console.log('cut-mode has been activated', cutActivated)
if (cutActivated) { if (cutActivated) {
if (state.copyElement.length > 1) { 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) => { const promisesToKeep = state.copyElement.filter(x => x).map(async (item) => {
console.log('cutting files now')
if (item.type === 'file') { if (item.type === 'file') {
props.dispatchMoveFile(item.key, feTarget[0].key) props.dispatchMoveFile(item.key, feTarget[0].key)
} else { } else {
@ -249,57 +217,60 @@ export const FileExplorer = (props: FileExplorerProps) => {
} }
} }
const CopyComboHandler = async (eve: KeyboardEvent) => { let CopyComboHandler: (eve: KeyboardEvent) => Promise<void>
if (eve.metaKey && eve.code === 'KeyC' && (window as any).navigator.userAgentData.platform === 'macOS') { let CutHandler: (eve: KeyboardEvent) => Promise<void>
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) let pasteHandler: (eve: KeyboardEvent) => Promise<void>
await performCopy() let pcCopyHandler: (eve: KeyboardEvent) => Promise<void>
console.log('copy performed on a mac') let pcCutHandler: (eve: KeyboardEvent) => Promise<void>
return 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) => { CutHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && (eve.key === 'c' || eve.key === 'C') && (window as any).navigator.userAgentData.platform !== 'macOS') { if (eve.metaKey && eve.code === 'KeyX') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
await performCopy() await performCut()
console.log('copy perfomed on a pc') return
return }
} }
}
const pcCutHandler = async (eve: KeyboardEvent) => { pasteHandler = async (eve: KeyboardEvent) => {
if (eve.ctrlKey && eve.code === 'KeyX' && (window as any).navigator.userAgentData.platform !== 'macOS') { if (eve.metaKey && eve.code === 'KeyV') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) feWindow._paq.push(['trackEvent', 'fileExplorer', 'metaVToPaste', 'PasteCopiedContent'])
await performCut() performPaste()
console.log('cut performed on a pc') return
return }
} }
} } else {
pcCopyHandler = async (eve: KeyboardEvent) => {
const CutHandler = async (eve: KeyboardEvent) => { if (eve.ctrlKey && (eve.key === 'c' || eve.key === 'C')) {
if (eve.metaKey && eve.code === 'KeyX' && (window as any).navigator.userAgentData.platform === 'macOS') { feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath']) await performCopy()
await performCut() return
console.log('Cut performed on mac') }
return
} }
}
const pasteHandler = async (eve: KeyboardEvent) => { pcCutHandler = async (eve: KeyboardEvent) => {
if (eve.metaKey && eve.code === 'KeyV' && (window as any).navigator.userAgentData.platform === 'macOS') { if (eve.ctrlKey && eve.code === 'KeyX') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'metaVToPaste', 'PasteCopiedContent']) feWindow._paq.push(['trackEvent', 'fileExplorer', 'f2ToRename', 'RenamePath'])
performPaste() await performCut()
console.log('paste performed on mac') return
return }
} }
}
const pcPasteHandler = async (eve: KeyboardEvent) => { pcPasteHandler = async (eve: KeyboardEvent) => {
if (eve.key === 'Control' && eve.code === 'KeyV' && (window as any).navigator.userAgentData.platform !== 'macOS') { if (eve.key === 'Control' && eve.code === 'KeyV') {
feWindow._paq.push(['trackEvent', 'fileExplorer', 'ctrlVToPaste', 'PasteCopiedContent']) feWindow._paq.push(['trackEvent', 'fileExplorer', 'ctrlVToPaste', 'PasteCopiedContent'])
performPaste() performPaste()
console.log('paste performed on pc') return
return }
} }
} }

@ -98,10 +98,10 @@
"@ethereumjs/util": "9.0.3", "@ethereumjs/util": "9.0.3",
"@ethereumjs/vm": "8.0.0", "@ethereumjs/vm": "8.0.0",
"@ethersphere/bee-js": "^3.2.0", "@ethersphere/bee-js": "^3.2.0",
"@floating-ui/react": "^0.26.15",
"@fortawesome/fontawesome-svg-core": "^6.5.1", "@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1", "@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0", "@fortawesome/react-fontawesome": "^0.2.0",
"@floating-ui/react": "^0.26.15",
"@gradio/client": "^0.10.1", "@gradio/client": "^0.10.1",
"@isomorphic-git/lightning-fs": "^4.4.1", "@isomorphic-git/lightning-fs": "^4.4.1",
"@metamask/eth-sig-util": "^7.0.2", "@metamask/eth-sig-util": "^7.0.2",
@ -252,6 +252,7 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@svgr/webpack": "^6.5.1", "@svgr/webpack": "^6.5.1",
"@testing-library/react": "13.4.0", "@testing-library/react": "13.4.0",
"@types/async": "^3.2.24",
"@types/axios": "^0.14.0", "@types/axios": "^0.14.0",
"@types/chai": "^4.3.3", "@types/chai": "^4.3.3",
"@types/express-ws": "^3.0.1", "@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" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc"
integrity sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig== 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": "@types/aws-lambda@^8.10.83":
version "8.10.130" version "8.10.130"
resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.130.tgz#d4a44201f0e47c8320a5868d845ad654f3b4adc2" resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.130.tgz#d4a44201f0e47c8320a5868d845ad654f3b4adc2"

Loading…
Cancel
Save