From f16dc33e149a8c3441b975e01bf269773089f26b Mon Sep 17 00:00:00 2001 From: Maxime Marinel Date: Wed, 5 Feb 2025 08:07:10 +0100 Subject: [PATCH] Fix delete confirm dialog Fix Justify Fix revenuecat --- App/Features/Entry/EntryView.swift | 20 ++++++++----------- .../Entry/UI/FontSizeSelectorView.swift | 2 +- App/Features/Entry/WebView.swift | 12 +++++++---- .../WallabagPlus/WallabagPlusStore.swift | 5 +++++ .../SharedLib/Extension/WKWebView.swift | 8 +++----- wallabag.xcodeproj/project.pbxproj | 4 ++-- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/App/Features/Entry/EntryView.swift b/App/Features/Entry/EntryView.swift index de22e604..453f858a 100644 --- a/App/Features/Entry/EntryView.swift +++ b/App/Features/Entry/EntryView.swift @@ -50,7 +50,6 @@ struct EntryView: View { } ToolbarItem(placement: toolbarPlacement) { FontSizeSelectorView() - .buttonStyle(.plain) } ToolbarItem(placement: toolbarPlacement) { Menu(content: { @@ -67,17 +66,14 @@ struct EntryView: View { }) } } - .actionSheet(isPresented: $showDeleteConfirm) { - ActionSheet( - title: Text("Confirm delete?"), - buttons: [ - .destructive(Text("Delete")) { - context.delete(entry) - dismiss() - }, - .cancel(), - ] - ) + .alert("Confirm delete?", isPresented: $showDeleteConfirm) { + Button(role: .destructive, action: { + context.delete(entry) + dismiss() + }, label: { + Text("Delete") + }) + Button("Cancel", role: .cancel) {} } .sheet(isPresented: $showTag) { TagListFor(entry: entry) diff --git a/App/Features/Entry/UI/FontSizeSelectorView.swift b/App/Features/Entry/UI/FontSizeSelectorView.swift index 94ae1fd5..8ad3cb56 100644 --- a/App/Features/Entry/UI/FontSizeSelectorView.swift +++ b/App/Features/Entry/UI/FontSizeSelectorView.swift @@ -8,7 +8,7 @@ struct FontSizeSelectorView: View { var body: some View { HStack { Button(action: { - withAnimation { + withAnimation(.smooth) { showSelector = !showSelector } }, label: { diff --git a/App/Features/Entry/WebView.swift b/App/Features/Entry/WebView.swift index 22e29c2e..72ac739e 100644 --- a/App/Features/Entry/WebView.swift +++ b/App/Features/Entry/WebView.swift @@ -27,9 +27,13 @@ import WebKit } func webViewToLastPosition() { - DispatchQueue.main.async { - self.webView.wkWebView.scrollView.setContentOffset(CGPoint(x: 0.0, y: self.webView.entry.screenPositionForWebView), animated: true) - } + webView.wkWebView.scrollView.setContentOffset( + CGPoint( + x: 0.0, + y: webView.entry.screenPositionForWebView + ), + animated: true + ) } func webView(_ webView: WKWebView, didFinish _: WKNavigation!) { @@ -77,7 +81,7 @@ import WebKit func makeUIView(context: Context) -> WKWebView { wkWebView.navigationDelegate = context.coordinator wkWebView.scrollView.delegate = context.coordinator - wkWebView.load(content: entry.content, justify: false) + wkWebView.load(content: entry.content, justify: UserDefaults.standard.bool(forKey: "justifyArticle")) return wkWebView } diff --git a/App/Features/WallabagPlus/WallabagPlusStore.swift b/App/Features/WallabagPlus/WallabagPlusStore.swift index d33ed51d..72835ed7 100644 --- a/App/Features/WallabagPlus/WallabagPlusStore.swift +++ b/App/Features/WallabagPlus/WallabagPlusStore.swift @@ -4,6 +4,7 @@ import RevenueCat @Observable final class WallabagPlusStore { + private let userDefaultKey = "REVENUECAT_SYNCED" @ObservationIgnored @BundleKey("REVENUECAT_KEY") private var revenueCatKey: String @@ -14,6 +15,10 @@ final class WallabagPlusStore { } func checkPro() async { + if !UserDefaults.standard.bool(forKey: userDefaultKey) { + _ = try? await Purchases.shared.syncPurchases() + UserDefaults.standard.set(true, forKey: userDefaultKey) + } proUnlocked = await (try? Purchases.shared.customerInfo(fetchPolicy: .fetchCurrent).entitlements.active.keys.contains("pro")) ?? false } } diff --git a/SharedLib/Sources/SharedLib/Extension/WKWebView.swift b/SharedLib/Sources/SharedLib/Extension/WKWebView.swift index 9dfef425..26339569 100644 --- a/SharedLib/Sources/SharedLib/Extension/WKWebView.swift +++ b/SharedLib/Sources/SharedLib/Extension/WKWebView.swift @@ -3,13 +3,11 @@ import WebKit public extension WKWebView { func load(content: String?, justify: Bool) { - DispatchQueue.main.async { [weak self] in - guard let content = self?.contentForWebView(content, justify: justify) else { return } - self?.loadHTMLString(content, baseURL: Bundle.main.bundleURL) - } + guard let content = contentForWebView(content, justify: justify) else { return } + loadHTMLString(content, baseURL: Bundle.main.bundleURL) } - func contentForWebView(_ content: String?, justify: Bool) -> String? { + nonisolated func contentForWebView(_ content: String?, justify: Bool) -> String? { do { guard let content else { return nil } let html = try String(contentsOfFile: Bundle.main.path(forResource: "article", ofType: "html")!) diff --git a/wallabag.xcodeproj/project.pbxproj b/wallabag.xcodeproj/project.pbxproj index c9ca2750..15c78f7d 100644 --- a/wallabag.xcodeproj/project.pbxproj +++ b/wallabag.xcodeproj/project.pbxproj @@ -1270,7 +1270,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 17.0; - MARKETING_VERSION = 7.5.0; + MARKETING_VERSION = 7.5.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -1329,7 +1329,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 17.0; - MARKETING_VERSION = 7.5.0; + MARKETING_VERSION = 7.5.2; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SWIFT_COMPILATION_MODE = wholemodule;