Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/Cleanup NetworkRequest and Related Code #4633

Merged
merged 12 commits into from
May 16, 2023

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented May 14, 2023

Description

This PR does many small changes - each commit can be reviewed on its own.

The following changes were made:

  • Cleanup unused code (Twitch v5)
  • Add json methods that simplify sending JSON. This also sets the Accepts header, since here, when JSON is sent, only JSON is accepted as a response (this is only done in Helix).
  • Helix's makeRequest now accepts an HTTP method.
  • Cleaned some clang-tidy suggestions in Network{Request,Private}. The only suggestions left there are (1) a const-cast and (2-5) unused QFuture's from QtConcurrent::run calls. (1) should be resolved when Remove QObjectRef in favor of QPointer #4632 is closed. (2-5) can be resolved by using QThreadPool::start, since we don't need the future.
  • Moved asserts to Q_ASSERT_X, which provides better error messages (mainly with a reasoning in the message).

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/common/NetworkRequest.cpp Outdated Show resolved Hide resolved
src/common/NetworkRequest.hpp Show resolved Hide resolved
src/common/NetworkRequest.hpp Show resolved Hide resolved
src/common/NetworkRequest.hpp Show resolved Hide resolved
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpicks, otherwise looks good

src/providers/twitch/api/Helix.hpp Outdated Show resolved Hide resolved
src/common/NetworkPrivate.cpp Outdated Show resolved Hide resolved
src/common/NetworkPrivate.cpp Outdated Show resolved Hide resolved
src/common/NetworkRequest.cpp Outdated Show resolved Hide resolved
src/common/NetworkRequest.hpp Outdated Show resolved Hide resolved
@Nerixyz Nerixyz force-pushed the refactor/network-request branch from 1df8848 to d886b41 Compare May 15, 2023 13:16
@Nerixyz
Copy link
Contributor Author

Nerixyz commented May 15, 2023

Constructing the url-query and json in Helix could be simplified by using the constructors taking initializer-lists.

@Nerixyz Nerixyz force-pushed the refactor/network-request branch from d886b41 to df1e012 Compare May 15, 2023 13:42
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes look good to me 👍
If you want to re-add the assert comments in any way feel free, will merge this in later

@pajlada pajlada merged commit ce47d27 into Chatterino:master May 16, 2023
@Nerixyz Nerixyz deleted the refactor/network-request branch May 16, 2023 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants