react-native-audio-browser 0.2.0-next.63 → 0.2.0-next.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,10 +6,14 @@ import NitroModules
6
6
  import os.log
7
7
 
8
8
  public extension HybridAudioBrowser {
9
- /// Navigates the in-app browser, reporting a failure as the navigation error. The clear is
10
- /// synchronous, so JS hears it before the navigation that may set the error again.
9
+ /// Navigates the in-app browser, superseding a configuration's pending start path, and reports
10
+ /// a failure as the navigation error. The clear is synchronous, so JS hears it before the
11
+ /// navigation that may set the error again.
11
12
  internal func navigate(_ path: String, clearError: Bool) {
12
- if clearError { onMainActor { navigationError.clear() } }
13
+ onMainActor {
14
+ initialNavigation?.cancel()
15
+ if clearError { navigationError.clear() }
16
+ }
13
17
  Task { @MainActor in await loadPath(path) }
14
18
  }
15
19
 
@@ -84,7 +88,7 @@ public extension HybridAudioBrowser {
84
88
  return browserManager.path == path
85
89
  }
86
90
  externalContentChangedEmitter.emit(path)
87
- if isCurrentPath { navigate(path, clearError: false) }
91
+ if isCurrentPath { Task { @MainActor in await loadPath(path) } }
88
92
  }
89
93
 
90
94
  func invalidateAllContent() throws {
@@ -55,6 +55,7 @@ public class HybridAudioBrowser: HybridAudioBrowserSpec, @unchecked Sendable {
55
55
  let browserManager = BrowserManager()
56
56
  let browseGate = BrowseGate()
57
57
  let trackSelector: TrackSelector
58
+ @MainActor private(set) var initialNavigation: Task<Void, Never>?
58
59
  @MainActor private(set) lazy var audioSession = AudioSessionController()
59
60
  // Player state set before the player exists, by setup options or the setters; last write wins,
60
61
  // consumed when the player comes up.
@@ -124,15 +125,17 @@ public class HybridAudioBrowser: HybridAudioBrowserSpec, @unchecked Sendable {
124
125
  onMainActor {
125
126
  browserManager.config = BrowserConfig(from: configuration)
126
127
  browserManager.clearContent()
128
+ initialNavigation?.cancel()
129
+ initialNavigation = Task {
130
+ let tabs = try? await browserManager.queryTabs()
131
+ guard !Task.isCancelled else { return }
132
+ navigate(configuredPath ?? tabs?.first?.path ?? "/", clearError: true)
133
+ }
127
134
  }
128
135
 
129
136
  Task { @MainActor in
130
137
  playerAndConfiguredBrowser.check()
131
138
  }
132
- Task {
133
- let tabs = try? await browserManager.queryTabs()
134
- navigate(configuredPath ?? tabs?.first?.path ?? "/", clearError: true)
135
- }
136
139
  }
137
140
  }
138
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-audio-browser",
3
- "version": "0.2.0-next.63",
3
+ "version": "0.2.0-next.64",
4
4
  "description": "react-native-audio-browser is a react native package built with Nitro",
5
5
  "keywords": [
6
6
  "react-native",