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

Add bookmarks to Wear app #549

Merged
merged 6 commits into from Apr 7, 2023
Merged

Add bookmarks to Wear app #549

merged 6 commits into from Apr 7, 2023

Conversation

yschimke
Copy link
Collaborator

@yschimke yschimke commented Apr 7, 2023

No description provided.

apolloClientCache.getClient(conference, uid).query(GetBookmarksQuery())
.tokenProvider(tokenProvider)
.fetchPolicy(fetchPolicy)
.execute()
.toFlow()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This can't be execute if we take fetchPolicy in as a parameter.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed. execute() is a bit awkward because of CacheAndNetwork that emits twice. There is a bit of brain muscle around it though so it's hard to change at this point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I might add a simple one so it's hidden from clients.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably an extension function to ApolloCall?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I follow. Soemthing like this?

ApolloCall.cacheAndNework()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure, I think I want ApolloCall.asStateFlow(fetchPolicy): StateFlow<Result<Data>> that hides all errors when it has any results to show. And a failed form if both network and cache failed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hiding errors is a bit risky. There's some background there where we did that for .watch() and some users required access to the individual errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What about Flow but it doesn't go from a a non null data, to null?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe yea. In all cases, I'd proceed with caution there as we've been burnt by this before (one instance there). Maybe keep the current toFlow() that emits everything and add helper functions on top of it. If it's StateFlow it can be one layer of abstraction above or so.

@@ -150,11 +150,15 @@ class ConfettiRepository : KoinComponent {
}
}

suspend fun sessionDetails(
fun sessionDetails(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It feels like we don't have a common plan for how to implement these. A similar issue happens with Room, for suspend functions vs Flow.

But especially here, it would be nice if we could hide away differences between CacheFirst, CandAndNetwork, NetworkFirst.

I'm unclear what happens when CacheAndNetwork, gets a valid cache result, but then fails on network. Does it silently drop it, so the cache result stands? Or show an error?

Copy link
Collaborator

Choose a reason for hiding this comment

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

what happens when CacheAndNetwork, gets a valid cache result, but then fails on network

It emits 2 ApolloResponse:

  • First one with apolloResponse.exception == null
  • Second one with apolloResponse.exception != null

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What about the data?

Should we ignore that second one? assume it's just network is down?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about the data?

  • First one with apolloResponse.data != null
  • Second one with apolloResponse.data == null

Should we ignore that second one? assume it's just network is down?

I would ignore it yes. And rely on pull to refresh if the user really want latest data.

To me:

  • initial load with CacheAndNetwork means: display something as soon as possible, update in the background
  • pull to refresh means: I always want fresh network results (or an error else)

The more I think about it, the less I like CacheAndNetwork though because it updates the data without user action which might feel a bit weird.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The more I think about it, the less I like CacheAndNetwork though because it updates the data without user action which might feel a bit weird.

I like that, but it's a change for mobile.

@@ -27,7 +27,7 @@ class SpeakerDetailsViewModel(

val speaker: StateFlow<UiState> = flow {
// FixMe: add .speaker(id)
val response = repository.conferenceData(conference = conference, FetchPolicy.CacheOnly)
val response = repository.conferenceData(conference = conference, FetchPolicy.CacheFirst)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

CacheFirst seems safer and more like what we want than CacheOnly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1. That'll fix a deeplink to a speaker details if the conference has never been opened before.
Also we should get only the speaker instead of retrieving all the conference data (I can do that in a follow up PR)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On the pages that are information focused, instead of action focused. I decided to make this more muted.

                    chipType = StandardChipType.Secondary

@yschimke yschimke marked this pull request as ready for review April 7, 2023 15:20
@joreilly joreilly merged commit 2467a69 into joreilly:main Apr 7, 2023
5 checks passed
@yschimke yschimke deleted the bookmarks branch April 9, 2023 08:40
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.

None yet

3 participants