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

Initial Login Infrastructure #78

Merged
merged 1 commit into from
Jul 23, 2024
Merged

Initial Login Infrastructure #78

merged 1 commit into from
Jul 23, 2024

Conversation

Rahkeen
Copy link
Collaborator

@Rahkeen Rahkeen commented Jul 22, 2024

This PR adds one core dependency and a bunch of infrastrucutre to support login and login-based actions.

Because HN doesn't have official API support for Login, Upvotes, Commenting, etc, the only way that clients can perform those actions is by requesting various web routes and scraping the HTML for data.

Added jsoup as a dependency to make working with HTML a lot nicer, as it also allows you to query HTML documents using CSS selectors.

Also created a WebClient which is reponsible for all things that require scraping the Hacker News website.

Lastly I CookieJar to our OkHttp client so that it can store the "auth cookie" when we successfully login. We need this cooking on all subsequent web client requests in order to get access to actions.

This PR adds one core dependency and a bunch of infrastrucutre to support login
and login-based actions.

Because HN doesn't have official API support for Login, Upvotes, Commenting, etc, the only
way that clients can perform those actions is by requesting various web routes and scraping
the HTML for data.

Added `jsoup` as a dependency to make working with HTML a lot nicer, as it also allows you to query HTML documents using CSS selectors.

Also created a `WebClient` which is reponsible for all things that require scraping the Hacker News website.

Lastly I `CookieJar` to our OkHttp client so that it can store the "auth cookie" when we successfully login. We need this cooking on all subsequent web client requests in order to get access to actions.
@Rahkeen Rahkeen requested a review from rbro112 July 22, 2024 21:27
Copy link

emerge-tools bot commented Jul 22, 2024

2 builds increased size

Name Version Download Change Install Change Approval
⚠️ Hacker News
com.emergetools.hackernews.debug
1.0 (1) 10.1 MB ⬆️ 547.4 kB (5.71%) 29.4 MB ⬆️ 1.5 MB (5.2%) N/A
⚠️ Hacker News
com.emergetools.hackernews
1.0 (1) 1.8 MB ⬆️ 291.6 kB (18.74%) 4.0 MB ⬆️ 640.1 kB (18.98%) N/A

Hacker News 1.0 (1)
com.emergetools.hackernews.debug

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 1.5 MB (5.2%)
Total download size change: ⬆️ 547.4 kB (5.71%)

Largest size changes

Item Install Size Change Download Size Change
📝 androidx.datastore.preferences.protobuf.MessageSchema ⬆️ 67.3 kB ⬆️ 23.8 kB
🗑 com.google.accompanist ⬇️ -33.0 kB ⬇️ -11.5 kB
📝 androidx.datastore.preferences.protobuf.BinaryReader$SafeHeapRead... ⬆️ 14.5 kB ⬆️ 5.1 kB
📝 org.jsoup.nodes.Element ⬆️ 14.0 kB ⬆️ 4.9 kB
📝 org.jsoup.parser.HtmlTreeBuilder ⬆️ 12.9 kB ⬆️ 4.6 kB
View Treemap

Image of diff

Hacker News 1.0 (1)
com.emergetools.hackernews

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 640.1 kB (18.98%)
Total download size change: ⬆️ 291.6 kB (18.74%)

Largest size changes

Item Install Size Change Download Size Change
📝 androidx.datastore.preferences.protobuf.MessageSchema ⬆️ 27.3 kB ⬆️ 12.4 kB
kotlin.text.CharsKt ⬇️ -18.8 kB ⬇️ -8.5 kB
📝 org.jsoup.Jsoup ⬆️ 18.2 kB ⬆️ 8.3 kB
📝 androidx.compose.foundation.text.BasicTextKt ⬆️ 14.4 kB ⬆️ 6.5 kB
📝 androidx.core.os.BundleKt ⬆️ 14.0 kB ⬆️ 6.4 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

Copy link

emerge-tools bot commented Jul 22, 2024

📸 Snapshot Test

5 modified, 2 added, 17 unchanged

Name Version Added Removed Modified Unchanged Errored Approval
Hacker News
com.emergetools.hackernews.debug
1.0 (1) 2 0 5 17 0 ✅ Approved

🛸 Powered by Emerge Tools

Copy link

emerge-tools bot commented Jul 22, 2024

⏱ Performance Analysis

Hacker News

Head build: Hacker News 1.0 (1)
Base build: Hacker News 1.0 (1)

Name Change Comparison
⚠️ Startup (com.emerge.universaltests.EmergeUniversalStartupTest) ⬆️ 10.52% 🛸 View

🛸 Powered by Emerge Tools

class HackerNewsWebClient(
private val httpClient: OkHttpClient,
) {
suspend fun login(username: String, password: String): LoginResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, this is a lot cleaner than I was imagining it being!

@@ -19,21 +19,20 @@ emergePlugin = "3.1.1"
emergeSnapshots = "1.1.2"
composeCompilerExtension = "1.5.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

No current action needed here (or soon), but was playing around with https://developer.android.com/develop/ui/compose/compiler the other day, would be good to move to that at some point in the near future, but again, no rush.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh snap, good mention. I'll put up a diff to move over soon.

@Rahkeen Rahkeen merged commit d315a62 into main Jul 23, 2024
5 checks passed
@Rahkeen Rahkeen deleted the rikin.login branch July 23, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants