Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

making feed screen look nicer #84

Merged
merged 2 commits into from
Jul 31, 2023
Merged

making feed screen look nicer #84

merged 2 commits into from
Jul 31, 2023

Conversation

JohnOberhauser
Copy link
Member

No description provided.


@GET("/api/v2/search")
suspend fun search(
@Query("q") query: String,
@Query("type") type: String,
) : SearchResult

@GET("/api/v1/accounts/{id}")
suspend fun getAccount(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required for this PR but I would strongly suggest we create separate API interfaces for the different official APIs instead of just one god MastodonAPI (AccountApi, StatusApi, etc.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably a good idea

// get in reply to account names
async {
status.inReplyToAccountId?.let { accountId ->
status.copy(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok 2 things here:

  1. I think it's really important for the service/network layer to be completely decoupled from business logic, and by adding the display name to the model returned by MastodonApi, we are coupling it to this repository. If we want to combine different models coming back from the API, IMO this should be done in a use case with a new model. That way, we don't have to deal with complicated logic to cache and reconcile different models, and instead it can all happen in a use case. Then our cache can also remain a pure model of the API.
  2. We shouldn't block the UI waiting for the display names. This is more reason for this to happen in a use case- it can return the statuses as-is immediately, and then update with the display names when it gets them

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I'll create a new network only model in the network module for this so we separate them. I think business logic is fine the repository class though. Repository classes are in the data module and not part of the service/network layer.
  2. I'm not sure about this. I think it's critical information to see the account name someone is replying to, and seeing things like that pop in wouldn't look very good. But either way, I'm thinking it won't be like this forever. I made a suggestion in daniel's new API improvements doc that should fix this https://docs.google.com/document/d/1uxJ8l83r-W9beWU1HYKlH2a4UIs8jz4Y42mp4YJfwgM/edit

Copy link
Member Author

@JohnOberhauser JohnOberhauser Jul 31, 2023

Choose a reason for hiding this comment

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

Actually, for the first one I'm going to do that in a separate PR. I think our whole model / network model stuff needs a big refactor

it.collect { feedType ->
when (feedType) {
FeedType.HOME -> getHomeTimeline()
FeedType.LOCAL -> {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this change? I don't think updating the timeline via the functions below will work anymore. This was setup to support switching feed types once we implement the UI

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to fix that in the future. I made some changes to the feed, like changing the flow to a stateFlow and removing the retrofit Response wrapper in favor of a try catch block so we can catch other errors besides network response issues.

@JohnOberhauser
Copy link
Member Author

I'm going to merge this now and fix the model stuff in a separate PR

@JohnOberhauser JohnOberhauser merged commit b7472af into main Jul 31, 2023
@JohnOberhauser JohnOberhauser deleted the feed1 branch July 31, 2023 22:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants