Skip to content

Commit 979e0e3

Browse files
Fix copy and paste on local backend (#11701)
* Fix copy and paste on local backend * Remove sorting order by modified date
1 parent bae9744 commit 979e0e3

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

app/common/src/services/Backend.ts

+7-14
Original file line numberDiff line numberDiff line change
@@ -1430,23 +1430,16 @@ export function detectVersionLifecycle(version: string) {
14301430
/** Return a positive number if `a > b`, a negative number if `a < b`, and zero if `a === b`. */
14311431
export function compareAssets(a: AnyAsset, b: AnyAsset) {
14321432
const relativeTypeOrder = ASSET_TYPE_ORDER[a.type] - ASSET_TYPE_ORDER[b.type]
1433+
14331434
if (relativeTypeOrder !== 0) {
14341435
return relativeTypeOrder
1435-
} else {
1436-
const aModified = Number(new Date(a.modifiedAt))
1437-
const bModified = Number(new Date(b.modifiedAt))
1438-
const modifiedDelta = aModified - bModified
1439-
if (modifiedDelta !== 0) {
1440-
// Sort by date descending, rather than ascending.
1441-
return -modifiedDelta
1442-
} else {
1443-
return (
1444-
a.title > b.title ? 1
1445-
: a.title < b.title ? -1
1446-
: 0
1447-
)
1448-
}
14491436
}
1437+
1438+
return (
1439+
a.title > b.title ? 1
1440+
: a.title < b.title ? -1
1441+
: 0
1442+
)
14501443
}
14511444

14521445
// ==================

app/gui/src/dashboard/components/dashboard/AssetRow.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import AssetListEventType from '#/events/AssetListEventType'
2727
import AssetContextMenu from '#/layouts/AssetContextMenu'
2828
import type * as assetsTable from '#/layouts/AssetsTable'
2929
import * as eventListProvider from '#/layouts/AssetsTable/EventListProvider'
30-
import { isCloudCategory } from '#/layouts/CategorySwitcher/Category'
30+
import { isCloudCategory, isLocalCategory } from '#/layouts/CategorySwitcher/Category'
3131
import * as localBackend from '#/services/LocalBackend'
3232

3333
import * as backendModule from '#/services/Backend'
@@ -422,6 +422,11 @@ export function RealAssetInternalRow(props: RealAssetRowInternalProps) {
422422
)
423423
nodeParentKeysRef.current = { nodeMap: new WeakRef(nodeMap.current), parentKeys }
424424
}
425+
426+
if (isLocalCategory(category)) {
427+
return true
428+
}
429+
425430
return payload.every((payloadItem) => {
426431
const parentKey = nodeParentKeysRef.current?.parentKeys.get(payloadItem.key)
427432
const parent = parentKey == null ? null : nodeMap.current.get(parentKey)
@@ -440,6 +445,7 @@ export function RealAssetInternalRow(props: RealAssetRowInternalProps) {
440445
})
441446
}
442447
})()
448+
443449
if ((isPayloadMatch && canPaste) || event.dataTransfer.types.includes('Files')) {
444450
event.preventDefault()
445451
if (asset.type === backendModule.AssetType.directory && state.category.type !== 'trash') {

0 commit comments

Comments
 (0)