mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
Reduce times we read upload data
This commit is contained in:
parent
a071f55c7b
commit
69a50c15c7
1 changed files with 5 additions and 6 deletions
|
@ -307,16 +307,16 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
QString mimeClass,
|
QString mimeClass,
|
||||||
const QString &fn,
|
const QString &fn,
|
||||||
const std::optional<RelatedInfo> &related) {
|
const std::optional<RelatedInfo> &related) {
|
||||||
QMimeDatabase db;
|
|
||||||
QMimeType mime = db.mimeTypeForData(dev.data());
|
|
||||||
|
|
||||||
if (!dev->open(QIODevice::ReadOnly)) {
|
if (!dev->open(QIODevice::ReadOnly)) {
|
||||||
emit uploadFailed(
|
emit uploadFailed(
|
||||||
QString("Error while reading media: %1").arg(dev->errorString()));
|
QString("Error while reading media: %1").arg(dev->errorString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bin = dev->peek(dev->size());
|
auto bin = dev->readAll();
|
||||||
|
QMimeDatabase db;
|
||||||
|
QMimeType mime = db.mimeTypeForData(bin);
|
||||||
|
|
||||||
auto payload = std::string(bin.data(), bin.size());
|
auto payload = std::string(bin.data(), bin.size());
|
||||||
std::optional<mtx::crypto::EncryptedFile> encryptedFile;
|
std::optional<mtx::crypto::EncryptedFile> encryptedFile;
|
||||||
if (cache::isRoomEncrypted(current_room_.toStdString())) {
|
if (cache::isRoomEncrypted(current_room_.toStdString())) {
|
||||||
|
@ -328,10 +328,9 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
QString blurhash;
|
QString blurhash;
|
||||||
if (mimeClass == "image") {
|
if (mimeClass == "image") {
|
||||||
dimensions = QImageReader(dev.data()).size();
|
|
||||||
|
|
||||||
QImage img;
|
QImage img;
|
||||||
img.loadFromData(bin);
|
img.loadFromData(bin);
|
||||||
|
dimensions = img.size();
|
||||||
if (img.height() > 200 && img.width() > 360)
|
if (img.height() > 200 && img.width() > 360)
|
||||||
img = img.scaled(360, 200, Qt::KeepAspectRatioByExpanding);
|
img = img.scaled(360, 200, Qt::KeepAspectRatioByExpanding);
|
||||||
std::vector<unsigned char> data;
|
std::vector<unsigned char> data;
|
||||||
|
|
Loading…
Reference in a new issue