Skip to content

Commit 5cdbc5b

Browse files
committed
Remove loadEditorTask synthesizing accessor
1 parent 1d53407 commit 5cdbc5b

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

ios/Sources/GutenbergKit/Sources/EditorViewController.swift

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ public final class EditorViewController: UIViewController, GutenbergEditorContro
242242

243243
// If we don't have dependencies yet, we need to load them
244244
if case .start = viewState {
245-
self.viewState = .loading(self.loadEditorTask)
245+
self.viewState = .loading(Task(priority: .userInitiated) {
246+
await self.prepareEditor()
247+
})
246248
}
247249

248250
// If we already have the dependencies, we can just load the editor right away
@@ -265,23 +267,24 @@ public final class EditorViewController: UIViewController, GutenbergEditorContro
265267
removeNavigationOverlay()
266268
}
267269

268-
@MainActor
269-
private var loadEditorTask: Task<Void, Never> {
270-
Task(priority: .userInitiated) {
271-
do {
272-
let dependencies = try await self.editorService.prepare { @MainActor progress in
273-
self.progressView.setProgress(progress, animated: true)
274-
}
275-
try self.loadEditor(dependencies: dependencies)
276-
277-
self.viewState = .loaded(dependencies)
278-
279-
} catch {
280-
self.viewState = .error(error)
270+
/// Fetch (or read from cache) everything the editor needs to launch
271+
///
272+
private func prepareEditor() async {
273+
do {
274+
let dependencies = try await self.editorService.prepare { @MainActor progress in
275+
self.progressView.setProgress(progress, animated: true)
281276
}
277+
try self.loadEditor(dependencies: dependencies)
278+
279+
self.viewState = .loaded(dependencies)
280+
281+
} catch {
282+
self.viewState = .error(error)
282283
}
283284
}
284285

286+
/// Load the editor JS into the webview
287+
///
285288
@MainActor
286289
private func loadEditor(dependencies: EditorDependencies) throws {
287290
self.bundleProvider.set(bundle: dependencies.assetBundle)

0 commit comments

Comments
 (0)