|
|
@@ -403,6 +403,7 @@ final class ViewController: NSViewController {
|
|
|
private let appUsageAccumulatedSecondsDefaultsKey = "rating.appUsageAccumulatedSeconds"
|
|
|
private let userHasRatedDefaultsKey = "rating.userHasRated"
|
|
|
private let ratingStateMigrationV2DoneDefaultsKey = "rating.stateMigrationV2Done"
|
|
|
+ private let nonPremiumJoinTrialConsumedDefaultsKey = "join.nonPremiumTrialConsumed"
|
|
|
private let ratingEligibleUsageSeconds: TimeInterval = 30 * 60
|
|
|
private var darkModeEnabled: Bool {
|
|
|
get {
|
|
|
@@ -412,6 +413,15 @@ final class ViewController: NSViewController {
|
|
|
set { UserDefaults.standard.set(newValue, forKey: darkModeDefaultsKey) }
|
|
|
}
|
|
|
|
|
|
+ private var nonPremiumJoinTrialConsumed: Bool {
|
|
|
+ get { UserDefaults.standard.bool(forKey: nonPremiumJoinTrialConsumedDefaultsKey) }
|
|
|
+ set { UserDefaults.standard.set(newValue, forKey: nonPremiumJoinTrialConsumedDefaultsKey) }
|
|
|
+ }
|
|
|
+
|
|
|
+ private var shouldGateJoinActionsForNonPremium: Bool {
|
|
|
+ !storeKitCoordinator.hasPremiumAccess && nonPremiumJoinTrialConsumed
|
|
|
+ }
|
|
|
+
|
|
|
private func makeSettingsPopover() -> NSPopover {
|
|
|
let popover = NSPopover()
|
|
|
popover.behavior = .transient
|
|
|
@@ -732,6 +742,11 @@ private extension ViewController {
|
|
|
@objc private func statusBarSignOutRequested() { performGoogleSignOut() }
|
|
|
|
|
|
@objc private func joinMeetClicked(_ sender: Any?) {
|
|
|
+ guard shouldGateJoinActionsForNonPremium == false else {
|
|
|
+ showPaywall()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
let rawInput = meetLinkField?.stringValue.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
|
|
|
|
guard let url = normalizedMeetJoinURL(from: rawInput) else {
|
|
|
@@ -743,6 +758,7 @@ private extension ViewController {
|
|
|
}
|
|
|
|
|
|
openInDefaultBrowser(url: url)
|
|
|
+ consumeNonPremiumJoinTrialIfNeeded()
|
|
|
}
|
|
|
|
|
|
@objc private func joinWithLinkCardClicked(_ sender: NSClickGestureRecognizer) {
|
|
|
@@ -783,8 +799,21 @@ private extension ViewController {
|
|
|
}
|
|
|
|
|
|
@objc private func instantMeetClicked(_ sender: NSClickGestureRecognizer) {
|
|
|
+ guard shouldGateJoinActionsForNonPremium == false else {
|
|
|
+ showPaywall()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
guard let url = URL(string: "https://meet.google.com/new") else { return }
|
|
|
openInDefaultBrowser(url: url)
|
|
|
+ consumeNonPremiumJoinTrialIfNeeded()
|
|
|
+ }
|
|
|
+
|
|
|
+ private func consumeNonPremiumJoinTrialIfNeeded() {
|
|
|
+ guard !storeKitCoordinator.hasPremiumAccess,
|
|
|
+ !nonPremiumJoinTrialConsumed else { return }
|
|
|
+ nonPremiumJoinTrialConsumed = true
|
|
|
+ refreshInstantMeetPremiumState()
|
|
|
}
|
|
|
|
|
|
private func normalizedURLString(from value: String) -> String {
|
|
|
@@ -1550,20 +1579,24 @@ private extension ViewController {
|
|
|
}
|
|
|
|
|
|
private func refreshInstantMeetPremiumState() {
|
|
|
- instantMeetCardView?.alphaValue = 1.0
|
|
|
- instantMeetTitleLabel?.alphaValue = 1.0
|
|
|
- instantMeetSubtitleLabel?.alphaValue = 1.0
|
|
|
- instantMeetCardView?.toolTip = nil
|
|
|
+ let isLocked = shouldGateJoinActionsForNonPremium
|
|
|
+ let lockedAlpha: CGFloat = 0.6
|
|
|
+
|
|
|
+ instantMeetCardView?.alphaValue = isLocked ? lockedAlpha : 1.0
|
|
|
+ instantMeetTitleLabel?.alphaValue = isLocked ? lockedAlpha : 1.0
|
|
|
+ instantMeetSubtitleLabel?.alphaValue = isLocked ? lockedAlpha : 1.0
|
|
|
+ instantMeetCardView?.toolTip = isLocked ? "Free trial used. Upgrade to continue." : nil
|
|
|
instantMeetCardView?.onHoverChanged?(false)
|
|
|
|
|
|
- joinWithLinkCardView?.alphaValue = 1.0
|
|
|
- joinWithLinkTitleLabel?.alphaValue = 1.0
|
|
|
- meetLinkField?.isEditable = true
|
|
|
- meetLinkField?.isSelectable = true
|
|
|
- meetLinkField?.alphaValue = 1.0
|
|
|
+ joinWithLinkCardView?.alphaValue = isLocked ? lockedAlpha : 1.0
|
|
|
+ joinWithLinkTitleLabel?.alphaValue = isLocked ? lockedAlpha : 1.0
|
|
|
+ meetLinkField?.isEditable = !isLocked
|
|
|
+ meetLinkField?.isSelectable = !isLocked
|
|
|
+ meetLinkField?.alphaValue = isLocked ? lockedAlpha : 1.0
|
|
|
joinMeetPrimaryButton?.isEnabled = true
|
|
|
- joinMeetPrimaryButton?.alphaValue = 1.0
|
|
|
- joinWithLinkCardView?.toolTip = nil
|
|
|
+ joinMeetPrimaryButton?.alphaValue = isLocked ? lockedAlpha : 1.0
|
|
|
+ joinMeetPrimaryButton?.toolTip = isLocked ? "Free trial used. Upgrade to continue." : nil
|
|
|
+ joinWithLinkCardView?.toolTip = isLocked ? "Free trial used. Upgrade to continue." : nil
|
|
|
}
|
|
|
|
|
|
private func handlePremiumAccessChanged(_ hasPremiumAccess: Bool) {
|