diff --git a/docs/ENV.md b/docs/ENV.md index 3fb19d802..00a680a27 100644 --- a/docs/ENV.md +++ b/docs/ENV.md @@ -27,7 +27,7 @@ Arguments: - None Notes: - - If you want to host the images yourself. You need [Nuuls' filehost software](https://github.com/nuuls/fiehost) + - If you want to host the images yourself. You need [Nuuls' filehost software](https://github.com/nuuls/filehost) - Other image hosting software is currently not supported. ### CHATTERINO2_TWITCH_SERVER_HOST @@ -42,4 +42,5 @@ Default value: `443` ### CHATTERINO2_TWITCH_SERVER_SECURE Bool value used to tell Chatterino whether to try to connect securely (secure irc) to the Twitch chat server. -Default value: `true` \ No newline at end of file +Default value: `true` + diff --git a/src/util/NuulsUploader.cpp b/src/util/NuulsUploader.cpp index cbf81beda..a51d5e877 100644 --- a/src/util/NuulsUploader.cpp +++ b/src/util/NuulsUploader.cpp @@ -11,7 +11,7 @@ namespace { -QString getImageFileFormat(QString path) +QString getImageFileFormat(const QString &path) { static QStringList listOfImageFormats = {".png", ".jpg", ".jpeg"}; for (const QString &format : listOfImageFormats) @@ -49,8 +49,8 @@ std::queue uploadQueue; void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel, ResizingTextEdit &textEdit) { - const char *boundary = "thisistheboudaryasd"; - QString contentType = + const static char *boundary = "thisistheboudaryasd"; + const static QString contentType = QString("multipart/form-data; boundary=%1").arg(boundary); static QUrl url(Env::get().imageUploaderUrl); @@ -86,12 +86,8 @@ void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel, "wait until all of them are uploaded. About %2 " "seconds left.") .arg(uploadQueue.size(), - uploadQueue.size() * - (UPLOAD_DELAY / 1000 + - 1) // convert UPLOAD_DELAY to seconds - ))); - // Argument number 2 is the ETA. - // 2 seconds for the timer that's there not to spam Nuuls' server + uploadQueue.size() * (UPLOAD_DELAY / 1000 + 1)))); + // 2 seconds for the timer that's there not to spam the remote server // and 1 second of actual uploading. QTimer::singleShot(UPLOAD_DELAY, [channel, &textEdit]() { @@ -156,6 +152,7 @@ void upload(const QMimeData *source, ChannelPtr channel, { channel->addMessage( makeSystemMessage(QString("Couldn't load image :("))); + isUploading = false; return; } @@ -183,6 +180,7 @@ void upload(const QMimeData *source, ChannelPtr channel, { channel->addMessage( makeSystemMessage(QString("Failed to open file. :("))); + isUploading = false; return; } RawImageData data = {file.readAll(), "gif"}; @@ -217,6 +215,7 @@ void upload(const QMimeData *source, ChannelPtr channel, { channel->addMessage(makeSystemMessage( QString("Cannot upload file, failed to convert to png."))); + isUploading = false; } } } diff --git a/src/util/NuulsUploader.hpp b/src/util/NuulsUploader.hpp index 192de31f6..0c059367d 100644 --- a/src/util/NuulsUploader.hpp +++ b/src/util/NuulsUploader.hpp @@ -9,6 +9,7 @@ struct RawImageData { QByteArray data; QString format; }; + void upload(QByteArray imageData, ChannelPtr channel, ResizingTextEdit &textEdit, std::string format); void upload(RawImageData imageData, ChannelPtr channel, diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index 60ccec58d..d26339130 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -301,7 +301,7 @@ void ResizingTextEdit::dropEvent(QDropEvent *event) { this->imagePasted.invoke(event->mimeData()); } - else // allow for previous functionality of dropping text. + else { QTextEdit::dropEvent(event); }