Skip to content

Commit 700d88f

Browse files
committed
Move background image upload work to a separate method in product form
1 parent 4b52f71 commit 700d88f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

WooCommerce/Classes/ViewRelated/Products/Edit Product/ProductFormViewController.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,8 @@ final class ProductFormViewController<ViewModel: ProductFormViewModelProtocol>:
194194
super.viewWillDisappear(animated)
195195

196196
view.endEditing(true)
197-
198-
if isBeingDismissedInAnyWay {
199-
let key = ProductImageUploaderKey(siteID: viewModel.productModel.siteID,
200-
productOrVariationID: productOrVariationID,
201-
isLocalID: !viewModel.productModel.existsRemotely)
202-
productImageUploader.startEmittingErrors(key: key)
203-
productImageUploader.sendBackgroundUploadNoticeIfNeeded(key: key, using: ServiceLocator.noticePresenter)
204-
}
197+
prepareForBackgroundUploadsUponDismissal()
198+
205199
}
206200

207201
override var shouldShowOfflineBanner: Bool {
@@ -1339,6 +1333,16 @@ private extension ProductFormViewController {
13391333
// MARK: - Navigation actions handling
13401334
//
13411335
private extension ProductFormViewController {
1336+
func prepareForBackgroundUploadsUponDismissal() {
1337+
guard isBeingDismissedInAnyWay else { return }
1338+
1339+
let key = ProductImageUploaderKey(siteID: viewModel.productModel.siteID,
1340+
productOrVariationID: productOrVariationID,
1341+
isLocalID: !viewModel.productModel.existsRemotely)
1342+
productImageUploader.startEmittingErrors(key: key)
1343+
productImageUploader.sendBackgroundUploadNoticeIfNeeded(key: key, using: ServiceLocator.noticePresenter)
1344+
}
1345+
13421346
func presentBackNavigationActionSheet(onDiscard: @escaping () -> Void = {}, onCancel: @escaping () -> Void = {}) {
13431347
let exitForm: () -> Void = {
13441348
presentationStyle.createExitForm(viewController: navigationController ?? self, completion: onDiscard)

0 commit comments

Comments
 (0)