More css stuffs
This commit is contained in:
@@ -27,8 +27,10 @@
|
||||
</div>
|
||||
|
||||
<div class="virtual-scroller-container">
|
||||
<div *ngIf="(bookState$ | async)?.error">
|
||||
<p class="no-books-text">Failed to load library's books!</p>
|
||||
<div class="no-books-container" *ngIf="(bookState$ | async)?.error">
|
||||
<p class="no-books-text">
|
||||
{{ entityType === 'Library' ? "Failed to load library's books!" : "Failed to load shelf's books!" }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="no-books-container" *ngIf="!(bookState$ | async)?.error && (bookState$ | async)?.loaded && (bookState$ | async)?.books?.length === 0">
|
||||
<p class="no-books-text">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { catchError, map, switchMap } from 'rxjs/operators';
|
||||
import { Book, BookMetadata, BookSetting } from '../model/book.model';
|
||||
import { BookState } from '../model/state/book-state.model';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject, Observable, of} from 'rxjs';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {catchError, map, switchMap, tap} from 'rxjs/operators';
|
||||
import {Book, BookMetadata, BookSetting} from '../model/book.model';
|
||||
import {BookState} from '../model/state/book-state.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -24,6 +24,13 @@ export class BookService {
|
||||
|
||||
private loadBooks(): void {
|
||||
this.http.get<Book[]>(this.url).pipe(
|
||||
tap(books => {
|
||||
this.bookStateSubject.next({
|
||||
books: books || [],
|
||||
loaded: true,
|
||||
error: null,
|
||||
});
|
||||
}),
|
||||
catchError(error => {
|
||||
this.bookStateSubject.next({
|
||||
books: null,
|
||||
@@ -32,13 +39,7 @@ export class BookService {
|
||||
});
|
||||
return of(null);
|
||||
})
|
||||
).subscribe(books => {
|
||||
this.bookStateSubject.next({
|
||||
books: books || [],
|
||||
loaded: true,
|
||||
error: null,
|
||||
});
|
||||
});
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
updateBookShelves(bookIds: Set<number | undefined>, shelvesToAssign: Set<number | undefined>, shelvesToUnassign: Set<number | undefined>): Observable<Book[]> {
|
||||
@@ -57,12 +58,12 @@ export class BookService {
|
||||
currentBooks[index] = updatedBook;
|
||||
}
|
||||
});
|
||||
this.bookStateSubject.next({ ...currentState, books: [...currentBooks] });
|
||||
this.bookStateSubject.next({...currentState, books: [...currentBooks]});
|
||||
return updatedBooks;
|
||||
}),
|
||||
catchError(error => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
this.bookStateSubject.next({ ...currentState, error: error.message });
|
||||
this.bookStateSubject.next({...currentState, error: error.message});
|
||||
throw error;
|
||||
})
|
||||
);
|
||||
@@ -72,7 +73,7 @@ export class BookService {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const currentBooks = currentState.books || [];
|
||||
const filteredBooks = currentBooks.filter(book => book.libraryId !== libraryId);
|
||||
this.bookStateSubject.next({ ...currentState, books: filteredBooks });
|
||||
this.bookStateSubject.next({...currentState, books: filteredBooks});
|
||||
}
|
||||
|
||||
removeBooksFromShelf(shelfId: number): void {
|
||||
@@ -82,7 +83,7 @@ export class BookService {
|
||||
...book,
|
||||
shelves: book.shelves?.filter(shelf => shelf.id !== shelfId),
|
||||
}));
|
||||
this.bookStateSubject.next({ ...currentState, books: updatedBooks });
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
getBookById(bookId: number): Observable<Book | undefined> {
|
||||
@@ -104,9 +105,9 @@ export class BookService {
|
||||
switchMap(updatedBook => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = (currentState.books || []).map(book =>
|
||||
book.id === updatedBook.id ? { ...book, lastReadTime: updatedBook.lastReadTime } : book
|
||||
book.id === updatedBook.id ? {...book, lastReadTime: updatedBook.lastReadTime} : book
|
||||
);
|
||||
this.bookStateSubject.next({ ...currentState, books: updatedBooks });
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
return [updatedBook];
|
||||
})
|
||||
);
|
||||
@@ -150,19 +151,19 @@ export class BookService {
|
||||
}
|
||||
|
||||
setBookMetadata(googleBookId: string, bookId: number): Observable<Book> {
|
||||
const requestBody = { googleBookId };
|
||||
const requestBody = {googleBookId};
|
||||
return this.http.put<Book>(`${this.url}/${bookId}/set-metadata`, requestBody).pipe(
|
||||
map(book => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const updatedBooks = (currentState.books || []).map(existingBook =>
|
||||
existingBook.id === book.id ? book : existingBook
|
||||
);
|
||||
this.bookStateSubject.next({ ...currentState, books: updatedBooks });
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
return book;
|
||||
}),
|
||||
catchError(error => {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
this.bookStateSubject.next({ ...currentState, error: error.message });
|
||||
this.bookStateSubject.next({...currentState, error: error.message});
|
||||
throw error;
|
||||
})
|
||||
);
|
||||
@@ -177,12 +178,12 @@ export class BookService {
|
||||
} else {
|
||||
updatedBooks.push(book);
|
||||
}
|
||||
this.bookStateSubject.next({ ...currentState, books: updatedBooks });
|
||||
this.bookStateSubject.next({...currentState, books: updatedBooks});
|
||||
}
|
||||
|
||||
handleRemovedBookIds(removedBookIds: Set<number>): void {
|
||||
const currentState = this.bookStateSubject.value;
|
||||
const filteredBooks = (currentState.books || []).filter(book => !removedBookIds.has(book.id));
|
||||
this.bookStateSubject.next({ ...currentState, books: filteredBooks });
|
||||
this.bookStateSubject.next({...currentState, books: filteredBooks});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
transition: transform $transitionDuration, left $transitionDuration;
|
||||
background-color: var(--surface-overlay);
|
||||
border-radius: $borderRadius;
|
||||
padding: 0.5rem 1.5rem;
|
||||
padding: 0.5rem 1.35rem;
|
||||
box-shadow: 0px 3px 5px rgba(0, 0, 0, .02), 0px 0px 2px rgba(0, 0, 0, .05), 0px 1px 4px rgba(0, 0, 0, .08);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
outline: 0 none;
|
||||
color: var(--text-color);
|
||||
cursor: pointer;
|
||||
padding: .75rem 1rem;
|
||||
padding: 0.75rem 0.5rem 0.75rem 1rem;
|
||||
border-radius: $borderRadius;
|
||||
transition: background-color $transitionDuration, box-shadow $transitionDuration;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user