-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Navigate and reload the frontend in place for the webview command #7163
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
Open
markfrancisonly
wants to merge
10
commits into
home-assistant:main
Choose a base branch
from
markfrancisonly:fix/command-webview-navigate-bus
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0d3e588
Navigate and reload the frontend in place for the webview command
markfrancisonly 6ee7422
Trim webview command targets and defer v2 delivery to a connected fro…
markfrancisonly 25b8af7
Merge branch 'main' into fix/command-webview-navigate-bus
markfrancisonly a511d08
Merge remote-tracking branch 'upstream/main' into fix/command-webview…
markfrancisonly b08e2b1
Replace the webview command mediators with deep link intents
markfrancisonly 8bb7ddf
Merge branch 'main' into fix/command-webview-navigate-bus
markfrancisonly c36c50e
Merge branch 'main' into fix/command-webview-navigate-bus
markfrancisonly 58e0465
Classify in-place navigation targets and drop the cross-server race
markfrancisonly 90f3a04
Restore the cache-dropping reload
markfrancisonly 9f43744
Keep the Automotive policy and the graph readiness for running deep l…
markfrancisonly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/main/kotlin/io/homeassistant/companion/android/util/ReloadRequestMediator.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package io.homeassistant.companion.android.util | ||
|
|
||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
| import kotlinx.coroutines.flow.MutableSharedFlow | ||
| import kotlinx.coroutines.flow.asSharedFlow | ||
|
|
||
| /** | ||
| * Carries reload requests from the server commands to the frontend. Requests emitted while the | ||
| * frontend is not open are dropped since there is nothing to reload. | ||
| */ | ||
| @Singleton | ||
| class ReloadRequestMediator @Inject constructor() { | ||
|
|
||
| private val _eventFlow = MutableSharedFlow<Unit>(extraBufferCapacity = 1) | ||
| val eventFlow = _eventFlow.asSharedFlow() | ||
|
|
||
| fun emitReloadRequestEvent() { | ||
| _eventFlow.tryEmit(Unit) | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
app/src/main/kotlin/io/homeassistant/companion/android/util/WebViewNavigationMediator.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package io.homeassistant.companion.android.util | ||
|
|
||
| import io.homeassistant.companion.android.common.data.servers.ServerManager | ||
| import io.homeassistant.companion.android.frontend.navigation.FrontendTarget | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
| import kotlinx.coroutines.flow.MutableSharedFlow | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.flow.asSharedFlow | ||
| import kotlinx.coroutines.flow.asStateFlow | ||
|
|
||
| /** | ||
| * Carries webview navigation requests from the server commands to the visible frontend. | ||
| */ | ||
| @Singleton | ||
| class WebViewNavigationMediator @Inject constructor() { | ||
|
markfrancisonly marked this conversation as resolved.
Outdated
|
||
|
|
||
| private val _visibleServerId = MutableStateFlow<Int?>(null) | ||
|
|
||
| /** The server shown by the visible frontend, or `null` when no frontend is visible. */ | ||
| val visibleServerId: StateFlow<Int?> = _visibleServerId.asStateFlow() | ||
|
|
||
| private val _navigationRequests = MutableSharedFlow<FrontendTarget>(extraBufferCapacity = 1) | ||
| val navigationRequests = _navigationRequests.asSharedFlow() | ||
|
|
||
| /** [ServerManager.SERVER_ID_ACTIVE] is normalized to `null` since it does not identify a server. */ | ||
| fun setVisibleServer(serverId: Int?) { | ||
| _visibleServerId.value = serverId?.takeUnless { it == ServerManager.SERVER_ID_ACTIVE } | ||
| } | ||
|
|
||
| fun requestNavigation(target: FrontendTarget) { | ||
| _navigationRequests.tryEmit(target) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.