From 3582762ace22312ad1741047e8977c5476605d47 Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 2 Jul 2021 20:11:50 +0800 Subject: [PATCH] fix: roll back new media preview loader which may cause image flash --- Mastodon/Info.plist | 22 ++++---- .../MediaPreviewImageViewController.swift | 56 +++++++++---------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Mastodon/Info.plist b/Mastodon/Info.plist index 1a9dadce9..cbb93eabf 100644 --- a/Mastodon/Info.plist +++ b/Mastodon/Info.plist @@ -2,17 +2,6 @@ - CFBundleURLTypes - - - CFBundleURLSchemes - - mastodon - - CFBundleURLName - org.joinmastodon.app - - CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -27,6 +16,17 @@ $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString $(MARKETING_VERSION) + CFBundleURLTypes + + + CFBundleURLName + org.joinmastodon.app + CFBundleURLSchemes + + mastodon + + + CFBundleVersion $(CURRENT_PROJECT_VERSION) ITSAppUsesNonExemptEncryption diff --git a/Mastodon/Scene/MediaPreview/Paging/Image/MediaPreviewImageViewController.swift b/Mastodon/Scene/MediaPreview/Paging/Image/MediaPreviewImageViewController.swift index 5ec82db97..1bc8fdb2a 100644 --- a/Mastodon/Scene/MediaPreview/Paging/Image/MediaPreviewImageViewController.swift +++ b/Mastodon/Scene/MediaPreview/Paging/Image/MediaPreviewImageViewController.swift @@ -70,35 +70,35 @@ extension MediaPreviewImageViewController { let previewImageViewContextMenuInteraction = UIContextMenuInteraction(delegate: self) previewImageView.addInteraction(previewImageViewContextMenuInteraction) - switch viewModel.item { - case .local(let meta): - self.previewImageView.imageView.image = meta.image - self.previewImageView.setup(image: meta.image, container: self.previewImageView, forceUpdate: true) - self.previewImageView.imageView.accessibilityLabel = self.viewModel.altText - case .status(let meta): - Nuke.loadImage( - with: meta.url, - into: self.previewImageView.imageView - ) { result in - switch result { - case .failure(let error): - break - case .success(let response): - self.previewImageView.setup(image: response.image, container: self.previewImageView, forceUpdate: true) - self.previewImageView.imageView.accessibilityLabel = self.viewModel.altText - } - } - } -// viewModel.image -// .receive(on: RunLoop.main) // use RunLoop prevent set image during zooming (TODO: handle transitioning state) -// .sink { [weak self] image in -// guard let self = self else { return } -// guard let image = image else { return } -// self.previewImageView.imageView.image = image -// self.previewImageView.setup(image: image, container: self.previewImageView, forceUpdate: true) -// self.previewImageView.imageView.accessibilityLabel = self.viewModel.altText +// switch viewModel.item { +// case .local(let meta): +// self.previewImageView.imageView.image = meta.image +// self.previewImageView.setup(image: meta.image, container: self.previewImageView, forceUpdate: true) +// self.previewImageView.imageView.accessibilityLabel = self.viewModel.altText +// case .status(let meta): +// Nuke.loadImage( +// with: meta.url, +// into: self.previewImageView.imageView +// ) { result in +// switch result { +// case .failure(let error): +// break +// case .success(let response): +// self.previewImageView.setup(image: response.image, container: self.previewImageView, forceUpdate: true) +// self.previewImageView.imageView.accessibilityLabel = self.viewModel.altText +// } // } -// .store(in: &disposeBag) +// } + viewModel.image + .receive(on: RunLoop.main) // use RunLoop prevent set image during zooming (TODO: handle transitioning state) + .sink { [weak self] image in + guard let self = self else { return } + guard let image = image else { return } + self.previewImageView.imageView.image = image + self.previewImageView.setup(image: image, container: self.previewImageView, forceUpdate: true) + self.previewImageView.imageView.accessibilityLabel = self.viewModel.altText + } + .store(in: &disposeBag) } }