Add moveFiles option to attach/merge and per-book delete in duplicate merger (#2833)
* Add moveFiles option to attach/merge and per-book delete in duplicate merger * Remove single-format restriction from attach-to-book action
This commit is contained in:
@@ -212,21 +212,17 @@ export class BookFileService {
|
||||
return this.http.post<DuplicateGroup[]>(`${this.url}/duplicates`, request);
|
||||
}
|
||||
|
||||
attachBookFiles(targetBookId: number, sourceBookIds: number[], deleteSourceBooks: boolean): Observable<Book> {
|
||||
attachBookFiles(targetBookId: number, sourceBookIds: number[], moveFiles: boolean): Observable<Book> {
|
||||
return this.http.post<Book>(`${this.url}/${targetBookId}/attach-file`, {
|
||||
sourceBookIds,
|
||||
deleteSourceBooks
|
||||
moveFiles
|
||||
}).pipe(
|
||||
tap(updatedBook => {
|
||||
const currentState = this.bookStateService.getCurrentBookState();
|
||||
const sourceIdSet = new Set(sourceBookIds);
|
||||
let updatedBooks = (currentState.books || []).map(book =>
|
||||
book.id === targetBookId ? updatedBook : book
|
||||
);
|
||||
|
||||
if (deleteSourceBooks) {
|
||||
const sourceIdSet = new Set(sourceBookIds);
|
||||
updatedBooks = updatedBooks.filter(book => !sourceIdSet.has(book.id));
|
||||
}
|
||||
).filter(book => !sourceIdSet.has(book.id));
|
||||
|
||||
this.bookStateService.updateBookState({
|
||||
...currentState,
|
||||
|
||||
Reference in New Issue
Block a user