Fix requestReview crash on macOS

This commit is contained in:
Thomas Ricouard 2023-02-16 13:22:04 +01:00
parent f1919305ab
commit ef7d75d3d5

View file

@ -12,8 +12,6 @@ import UIKit
import StoreKit
public struct StatusEditorView: View {
@Environment(\.requestReview) var requestReview
@EnvironmentObject private var preferences: UserPreferences
@EnvironmentObject private var theme: Theme
@EnvironmentObject private var client: Client
@ -199,7 +197,9 @@ public struct StatusEditorView: View {
NotificationCenter.default.post(name: NotificationsName.shareSheetClose,
object: nil)
if !viewModel.mode.isInShareExtension && !preferences.requestedReview {
requestReview()
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
SKStoreReviewController.requestReview(in: scene)
}
preferences.requestedReview = true
}
}