Skip to content

Commit

Permalink
Fix displayRequests scopes and delete ForegroundScope
Browse files Browse the repository at this point in the history
  • Loading branch information
jyaganeh committed Jul 31, 2024
1 parent 1a8c125 commit 079977c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.runtime.structuralEqualityPolicy
import androidx.compose.ui.platform.LocalContext
Expand Down Expand Up @@ -106,11 +107,12 @@ internal fun rememberAirshipEmbeddedViewState(
): AirshipEmbeddedViewState {
val context = LocalContext.current
val state = remember { AirshipEmbeddedViewState(embeddedId) }
val scope = rememberCoroutineScope()

LaunchedEffect(key1 = embeddedId) {
// Collect display requests and update the current layout state.
withContext(Dispatchers.Default) {
embeddedViewManager.displayRequests(embeddedId, comparator)
embeddedViewManager.displayRequests(embeddedId, comparator, scope)
.map { request ->
if (request == null) {
// Nothing to display.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public class AirshipEmbeddedView private constructor(
private fun collectDisplayRequests() {
displayRequestsJob = viewScope.launch {
try {
manager.displayRequests(embeddedViewId = id, comparator = comparator)
manager.displayRequests(embeddedViewId = id, comparator = comparator, scope = viewScope)
.collect(::onUpdate)
} catch (e: CancellationException) {
UALog.v { "Stopped collecting display requests for $logTag" }
Expand Down
54 changes: 0 additions & 54 deletions urbanairship-core/src/main/java/com/urbanairship/AirshipScope.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package com.urbanairship.android.layout

import androidx.annotation.RestrictTo
import com.urbanairship.AirshipScopes
import com.urbanairship.UALog
import com.urbanairship.android.layout.display.DisplayArgs
import com.urbanairship.android.layout.info.LayoutInfo
Expand Down Expand Up @@ -70,6 +69,6 @@ public interface AirshipEmbeddedViewManager {
public fun displayRequests(
embeddedViewId: String,
comparator: Comparator<AirshipEmbeddedInfo>? = null,
scope: CoroutineScope = AirshipScopes.AppForegroundScope,
scope: CoroutineScope
): Flow<EmbeddedDisplayRequest?>
}

0 comments on commit 079977c

Please sign in to comment.