Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(frontend:spaces): ensure correct file ID assignment for new shares and anchored files

johaven023adfb879c0
diff --git a/frontend/src/app/applications/spaces/components/dialogs/space-anchor-file-dialog.component.ts b/frontend/src/app/applications/spaces/components/dialogs/space-anchor-file-dialog.component.ts
index c58ff3aa..b4acb276 100644
--- a/frontend/src/app/applications/spaces/components/dialogs/space-anchor-file-dialog.component.ts
+++ b/frontend/src/app/applications/spaces/components/dialogs/space-anchor-file-dialog.component.ts
@@ -31,7 +31,7 @@ import { SpaceManageRootsComponent } from '../utils/space-manage-roots.component
})
export class SpaceAnchorFileDialogComponent implements OnInit {
@Input({ required: true }) files: FileModel[]
- public addAnchoredFiles = new EventEmitter<{ space: SpaceModel; fileNames: string[] }>()
+ public addAnchoredFiles = new EventEmitter<{ space: SpaceModel; rootFiles: { id: number; name: string }[] }>()
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
protected readonly layout = inject(LayoutService)
protected readonly icons = { faAnchor, faPlus, faSpinner, SPACES: SPACES_ICON.SPACES }
@@ -81,7 +81,7 @@ export class SpaceAnchorFileDialogComponent implements OnInit {
if (roots.length) {
this.addAnchoredFiles.emit({
space: this.selectedSpace,
- fileNames: roots.map((r: SpaceRootModel): string => r.file.path.split('/').at(-1))
+ rootFiles: roots.map((r: SpaceRootModel) => ({ id: r.file.id, name: r.file.path.split('/').at(-1) }))
})
}
this.layout.closeDialog()
diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
index e3d805a9..e9e7e932 100644
--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
@@ -510,7 +510,9 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
} as ShareDialogComponent
})
modalRef.content.shareChange.pipe(take(1)).subscribe((r: ['add' | string, ShareModel]) => {
- this.selection[0].shares.push({ id: r[1].id, alias: r[1].alias, name: r[1].name, type: SHARE_TYPE.COMMON })
+ const s = r[1]
+ if (this.selection[0].id < 0) this.selection[0].id = s.file.id
+ this.selection[0].shares.push({ id: s.id, alias: s.alias, name: s.name, type: SHARE_TYPE.COMMON })
})
}
@@ -527,6 +529,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
modalRef.content.shareChange.pipe(take(1)).subscribe((r: ['update' | 'delete', ShareLinkModel] | ['add', ShareModel]) => {
const [action, s] = r
if (action === 'add') {
+ if (this.selection[0].id < 0) this.selection[0].id = s.file.id
this.selection[0].links.push({ id: s.id, alias: s.alias, name: s.name, type: SHARE_TYPE.LINK })
}
})
@@ -536,9 +539,11 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
const modalRef: BsModalRef<SpaceAnchorFileDialogComponent> = this.layout.openDialog(SpaceAnchorFileDialogComponent, 'lg', {
initialState: { files: this.selection } as SpaceAnchorFileDialogComponent
})
- modalRef.content.addAnchoredFiles.pipe(take(1)).subscribe((up: { space: SpaceModel; fileNames: string[] }) => {
- for (const f of this.files) {
- if (up.fileNames.indexOf(f.name) > -1 && f.spaces.map((s: Partial<SpaceModel>) => s.id).indexOf(up.space.id) === -1) {
+ modalRef.content.addAnchoredFiles.pipe(take(1)).subscribe((up: { space: SpaceModel; rootFiles: { id: number; name: string }[] }) => {
+ for (const f of this.selection) {
+ const rootFile = up.rootFiles.find((rf: { id: number; name: string }) => rf.name === f.name)
+ if (rootFile && f.spaces.map((s: Partial<SpaceModel>) => s.id).indexOf(up.space.id) === -1) {
+ if (f.id < 0) f.id = rootFile.id
f.spaces.push(up.space)
}
}