Update the UI when a client synchronizes back the libraries

Only the top banners for now. 

TODO: ComicModel should also be updated.
This commit is contained in:
Luis Ángel San Martín 2022-10-15 11:52:34 +02:00
parent e7b6f46cd3
commit d8a35d767c
7 changed files with 12 additions and 0 deletions

View File

@ -2818,6 +2818,12 @@ void LibraryWindow::importLibraryPackage()
importLibraryDialog->open(libraries); importLibraryDialog->open(libraries);
} }
void LibraryWindow::updateViewsOnClientSync()
{
contentViewsManager->updateCurrentComicView();
contentViewsManager->updateContinueReadingView();
}
void LibraryWindow::updateViewsOnComicUpdateWithId(quint64 libraryId, quint64 comicId) void LibraryWindow::updateViewsOnComicUpdateWithId(quint64 libraryId, quint64 comicId)
{ {
if (libraryId == (quint64)libraries.getId(selectedLibrary->currentText())) { if (libraryId == (quint64)libraries.getId(selectedLibrary->currentText())) {

View File

@ -385,6 +385,7 @@ public slots:
void showContinueReadingContextMenu(QPoint point, ComicDB comic); void showContinueReadingContextMenu(QPoint point, ComicDB comic);
void libraryAlreadyExists(const QString &name); void libraryAlreadyExists(const QString &name);
void importLibraryPackage(); void importLibraryPackage();
void updateViewsOnClientSync();
void updateViewsOnComicUpdateWithId(quint64 libraryId, quint64 comicId); void updateViewsOnComicUpdateWithId(quint64 libraryId, quint64 comicId);
void updateViewsOnComicUpdate(quint64 libraryId, const ComicDB &comic); void updateViewsOnComicUpdate(quint64 libraryId, const ComicDB &comic);
void showComicVineScraper(); void showComicVineScraper();

View File

@ -257,6 +257,7 @@ int main(int argc, char **argv)
mw->connect(localServer, &YACReaderLocalServer::comicUpdated, mw, &LibraryWindow::updateViewsOnComicUpdate, Qt::QueuedConnection); mw->connect(localServer, &YACReaderLocalServer::comicUpdated, mw, &LibraryWindow::updateViewsOnComicUpdate, Qt::QueuedConnection);
mw->connect(httpServer, &YACReaderHttpServer::comicUpdated, mw, &LibraryWindow::updateViewsOnComicUpdateWithId, Qt::QueuedConnection); mw->connect(httpServer, &YACReaderHttpServer::comicUpdated, mw, &LibraryWindow::updateViewsOnComicUpdateWithId, Qt::QueuedConnection);
mw->connect(httpServer, &YACReaderHttpServer::clientSync, mw, &LibraryWindow::updateViewsOnClientSync, Qt::QueuedConnection);
// connections to localServer // connections to localServer
// start as tray // start as tray

View File

@ -273,6 +273,7 @@ void RequestMapper::serviceV2(HttpRequest &request, HttpResponse &response)
VersionController().service(request, response); VersionController().service(request, response);
} else if (sync.exactMatch(path)) { } else if (sync.exactMatch(path)) {
SyncControllerV2().service(request, response); SyncControllerV2().service(request, response);
emit clientSync();
} else { } else {
if (library.indexIn(path) != -1 && DBHelper::getLibraries().contains(library.cap(1).toInt())) { if (library.indexIn(path) != -1 && DBHelper::getLibraries().contains(library.cap(1).toInt())) {
if (folderInfo.exactMatch(path)) { if (folderInfo.exactMatch(path)) {

View File

@ -21,6 +21,7 @@ public:
void loadSessionV2(stefanfrings::HttpRequest &request, stefanfrings::HttpResponse &response); void loadSessionV2(stefanfrings::HttpRequest &request, stefanfrings::HttpResponse &response);
signals: signals:
void clientSync();
void comicUpdated(qulonglong libraryId, qulonglong comicId); void comicUpdated(qulonglong libraryId, qulonglong comicId);
private: private:

View File

@ -141,6 +141,7 @@ void YACReaderHttpServer::start(quint16 port)
listener = new HttpListener(listenerSettings, requestMapper, app); listener = new HttpListener(listenerSettings, requestMapper, app);
connect(requestMapper, &RequestMapper::comicUpdated, this, &YACReaderHttpServer::comicUpdated); connect(requestMapper, &RequestMapper::comicUpdated, this, &YACReaderHttpServer::comicUpdated);
connect(requestMapper, &RequestMapper::clientSync, this, &YACReaderHttpServer::clientSync);
if (listener->isListening()) { if (listener->isListening()) {
qDebug("ServiceHelper: Service has started"); qDebug("ServiceHelper: Service has started");

View File

@ -20,6 +20,7 @@ public:
QString getPort(); QString getPort();
signals: signals:
void clientSync();
void comicUpdated(qulonglong libraryId, qulonglong comicId); void comicUpdated(qulonglong libraryId, qulonglong comicId);
private: private: