mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Implement /ignore and /unignore commands
Simplify authorized network requests for Twitch V5 api add onShow virtual function to settings pages if they need to be refreshed when shown Actually ignoring messages from ignored users is still not implemented Working on #247
This commit is contained in:
parent
5b26cdaa07
commit
937fffc34b
2 changed files with 49 additions and 1 deletions
|
@ -55,7 +55,6 @@ public:
|
|||
bool isAnon() const;
|
||||
|
||||
void loadIgnores();
|
||||
|
||||
void ignore(const QString &targetName,
|
||||
std::function<void(IgnoreResult, const QString &)> onFinished);
|
||||
void ignoreByID(const QString &targetUserID, const QString &targetName,
|
||||
|
|
|
@ -151,15 +151,26 @@ public:
|
|||
}
|
||||
|
||||
void setRawHeader(const char *headerName, const char *value)
|
||||
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
|
||||
=======
|
||||
{
|
||||
this->data.request.setRawHeader(headerName, value);
|
||||
}
|
||||
|
||||
void setRawHeader(const char *headerName, const QByteArray &value)
|
||||
>>>>>>> Implement /ignore and /unignore commands
|
||||
{
|
||||
this->data.request.setRawHeader(headerName, value);
|
||||
}
|
||||
|
||||
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
|
||||
void setRawHeader(const char *headerName, const QByteArray &value)
|
||||
{
|
||||
this->data.request.setRawHeader(headerName, value);
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> Implement /ignore and /unignore commands
|
||||
void setRawHeader(const char *headerName, const QString &value)
|
||||
{
|
||||
this->data.request.setRawHeader(headerName, value.toUtf8());
|
||||
|
@ -302,16 +313,28 @@ public:
|
|||
void execute()
|
||||
{
|
||||
switch (this->data.requestType) {
|
||||
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
|
||||
case GetRequest: {
|
||||
this->executeGet();
|
||||
} break;
|
||||
|
||||
case PutRequest: {
|
||||
=======
|
||||
case GET: {
|
||||
this->executeGet();
|
||||
} break;
|
||||
|
||||
case PUT: {
|
||||
>>>>>>> Implement /ignore and /unignore commands
|
||||
debug::Log("Call PUT request!");
|
||||
this->executePut();
|
||||
} break;
|
||||
|
||||
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
|
||||
case DeleteRequest: {
|
||||
=======
|
||||
case DELETE: {
|
||||
>>>>>>> Implement /ignore and /unignore commands
|
||||
debug::Log("Call DELETE request!");
|
||||
this->executeDelete();
|
||||
} break;
|
||||
|
@ -369,6 +392,7 @@ private:
|
|||
worker->moveToThread(&NetworkManager::workerThread);
|
||||
|
||||
if (this->data.caller != nullptr) {
|
||||
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
|
||||
QObject::connect(worker, &NetworkWorker::doneUrl,
|
||||
this->data.caller, [data = this->data](auto reply) mutable {
|
||||
auto &dat = data;
|
||||
|
@ -377,6 +401,12 @@ private:
|
|||
if (data.onError) {
|
||||
data.onError(reply->error());
|
||||
}
|
||||
=======
|
||||
QObject::connect(worker, &NetworkWorker::doneUrl,
|
||||
this->data.caller, [data = this->data](auto reply) mutable {
|
||||
if (reply->error() != QNetworkReply::NetworkError::NoError) {
|
||||
// TODO: We might want to call an onError callback here
|
||||
>>>>>>> Implement /ignore and /unignore commands
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -395,6 +425,7 @@ private:
|
|||
}
|
||||
|
||||
QObject::connect(&requester, &NetworkRequester::requestUrl, worker,
|
||||
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
|
||||
[ timer, data = std::move(this->data), worker ]() {
|
||||
QNetworkReply *reply;
|
||||
switch (data.requestType) {
|
||||
|
@ -407,6 +438,20 @@ private:
|
|||
} break;
|
||||
|
||||
case DeleteRequest: {
|
||||
=======
|
||||
[ timer, data = std::move(this->data), worker ]() {
|
||||
QNetworkReply *reply;
|
||||
switch (data.requestType) {
|
||||
case GET: {
|
||||
reply = NetworkManager::NaM.get(data.request);
|
||||
} break;
|
||||
|
||||
case PUT: {
|
||||
reply = NetworkManager::NaM.put(data.request, data.payload);
|
||||
} break;
|
||||
|
||||
case DELETE: {
|
||||
>>>>>>> Implement /ignore and /unignore commands
|
||||
reply = NetworkManager::NaM.deleteResource(data.request);
|
||||
} break;
|
||||
}
|
||||
|
@ -431,7 +476,11 @@ private:
|
|||
}
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, worker,
|
||||
<<<<<<< 5b26cdaa0777562a0b3c663a203528eca56bd5df
|
||||
[ data = std::move(data), worker, reply ]() mutable {
|
||||
=======
|
||||
[ data = std::move(data), worker, reply ]() mutable {
|
||||
>>>>>>> Implement /ignore and /unignore commands
|
||||
if (data.caller == nullptr) {
|
||||
QByteArray bytes = reply->readAll();
|
||||
data.writeToCache(bytes);
|
||||
|
|
Loading…
Reference in a new issue