chore: app group optimizations (#1027)
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { WebApplication } from '@/UIModels/Application'
|
||||
|
||||
const isBackupRelatedFile = (item: DataTransferItem, application: WebApplication): boolean => {
|
||||
const fileName = item.getAsFile()?.name || ''
|
||||
const isBackupMetadataFile = application.files.isFileNameFileBackupRelated(fileName) !== false
|
||||
return isBackupMetadataFile
|
||||
}
|
||||
|
||||
export const isHandlingFileDrag = (event: DragEvent, application: WebApplication) => {
|
||||
const items = event.dataTransfer?.items
|
||||
|
||||
@@ -8,10 +14,7 @@ export const isHandlingFileDrag = (event: DragEvent, application: WebApplication
|
||||
}
|
||||
|
||||
return Array.from(items).some((item) => {
|
||||
const isFile = item.kind === 'file'
|
||||
const fileName = item.getAsFile()?.name || ''
|
||||
const isBackupMetadataFile = application.files.isFileNameFileBackupMetadataFile(fileName)
|
||||
return isFile && !isBackupMetadataFile
|
||||
return item.kind === 'file' && !isBackupRelatedFile(item, application)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -23,9 +26,6 @@ export const isHandlingBackupDrag = (event: DragEvent, application: WebApplicati
|
||||
}
|
||||
|
||||
return Array.from(items).every((item) => {
|
||||
const isFile = item.kind === 'file'
|
||||
const fileName = item.getAsFile()?.name || ''
|
||||
const isBackupMetadataFile = application.files.isFileNameFileBackupMetadataFile(fileName)
|
||||
return isFile && isBackupMetadataFile
|
||||
return item.kind === 'file' && isBackupRelatedFile(item, application)
|
||||
})
|
||||
}
|
||||
10
app/assets/javascripts/Utils/PreactUtils.ts
Normal file
10
app/assets/javascripts/Utils/PreactUtils.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { render } from 'preact'
|
||||
|
||||
/**
|
||||
* Source: https://stackoverflow.com/questions/50946950/how-to-destroy-root-preact-node
|
||||
* For some reason importing `import { unmountComponentAtNode } from 'preact/compat'` inside of app/index.tsx
|
||||
* results in the app failing to compile.
|
||||
*/
|
||||
export function unmountComponentAtRoot(root: HTMLElement) {
|
||||
render(null, root)
|
||||
}
|
||||
@@ -134,6 +134,16 @@ if (!IsWebPlatform && !IsDesktopPlatform) {
|
||||
throw Error('Neither __WEB__ nor __DESKTOP__ is true. Check your configuration files.')
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function destroyAllObjectProperties(object: any): void {
|
||||
for (const prop of Object.getOwnPropertyNames(object)) {
|
||||
try {
|
||||
delete object[prop]
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (error) {}
|
||||
}
|
||||
}
|
||||
|
||||
export function isDesktopApplication() {
|
||||
return IsDesktopPlatform
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user