Skip to content

Commit

Permalink
fix: reduce workload
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhas committed Feb 7, 2021
1 parent 442d37f commit dc31078
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 22 deletions.
1 change: 0 additions & 1 deletion backend/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ module.exports = function (args, socket) {
const final = results[0];
final.today_list = results[1];
socket.write(JSON.stringify(final));
socket.write("\n");
socket.end();
})
.catch(err => {
Expand Down
1 change: 0 additions & 1 deletion backend/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ module.exports = function (args, socket) {
}
});
socket.write(JSON.stringify(books));
socket.write("\n");
socket.end();
}
}
1 change: 0 additions & 1 deletion backend/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module.exports = function (args, socket) {
dlUrl,
similars,
}));
socket.write("\n");
socket.end();
})
.catch(err => {
Expand Down
18 changes: 0 additions & 18 deletions grayImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,6 @@ class AsyncImageResponse : public QQuickImageResponse

QByteArray bytes = rep->readAll();
QImage img = QImage::fromData(bytes).convertToFormat(QImage::Format_Grayscale8);

int w = m_requestedSize.width(), h = m_requestedSize.height();
if (w != -1)
{
if (h != -1)
{
img = img.scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
else
{
img = img.scaledToWidth(w, Qt::SmoothTransformation);
}
}
else if (h != -1)
{
img = img.scaledToHeight(h, Qt::SmoothTransformation);
}

_img = img;
emit finished();
});
Expand Down
6 changes: 5 additions & 1 deletion store.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "store.h"

bool initialInfo = true;
Worker *infoThread = nullptr;

Store::Store() : rootView(rootObject()), context(rootContext())
Expand Down Expand Up @@ -34,6 +35,10 @@ Store::Store() : rootView(rootObject()), context(rootContext())
connect(worker, &Worker::socketClosed, this, [this]() {
context->setContextProperty("titleVisible", QVariant(false));
setProperty("isBusy", false);
if (initialInfo) {
infoThread->work();
initialInfo = false;
}
});
connect(worker, &Worker::readAll, this, [this](QByteArray bytes) {
if (booksParent != nullptr) {
Expand Down Expand Up @@ -168,7 +173,6 @@ void Store::open()
}
emit downloadListChanged();
});
infoThread->work();
}
else
{
Expand Down

0 comments on commit dc31078

Please sign in to comment.