fix attach file without move when source/target have different library paths (#2999)

This commit is contained in:
ACX
2026-02-25 16:17:34 -07:00
committed by GitHub
parent f1bf5246ec
commit a8c356297c
5 changed files with 100 additions and 22 deletions
@@ -212,17 +212,17 @@ export class BookFileService {
return this.http.post<DuplicateGroup[]>(`${this.url}/duplicates`, request);
}
attachBookFiles(targetBookId: number, sourceBookIds: number[], moveFiles: boolean): Observable<Book> {
return this.http.post<Book>(`${this.url}/${targetBookId}/attach-file`, {
attachBookFiles(targetBookId: number, sourceBookIds: number[], moveFiles: boolean): Observable<{updatedBook: Book, deletedSourceBookIds: number[]}> {
return this.http.post<{updatedBook: Book, deletedSourceBookIds: number[]}>(`${this.url}/${targetBookId}/attach-file`, {
sourceBookIds,
moveFiles
}).pipe(
tap(updatedBook => {
tap(response => {
const currentState = this.bookStateService.getCurrentBookState();
const sourceIdSet = new Set(sourceBookIds);
const deletedIdSet = new Set(response.deletedSourceBookIds);
let updatedBooks = (currentState.books || []).map(book =>
book.id === targetBookId ? updatedBook : book
).filter(book => !sourceIdSet.has(book.id));
book.id === targetBookId ? response.updatedBook : book
).filter(book => !deletedIdSet.has(book.id));
this.bookStateService.updateBookState({
...currentState,