Quellcode durchsuchen

Remove desktop widgets when premium access is revoked.

Made-with: Cursor
huzaifahayat12 vor 1 Monat
Ursprung
Commit
7ea689960a

+ 1 - 0
meetings_app/ViewController.swift

@@ -1581,6 +1581,7 @@ private extension ViewController {
1581 1581
         }
1582 1582
         if hadPremiumAccess && !hasPremiumAccess {
1583 1583
             MeetingReminderManager.shared.cancelAllReminders()
1584
+            DesktopWidgetWindowManager.shared.removeAllInstances()
1584 1585
             showPaywall()
1585 1586
         }
1586 1587
     }

+ 14 - 0
meetings_app/Widgets/DesktopWidgetWindowManager.swift

@@ -57,6 +57,20 @@ final class DesktopWidgetWindowManager: ObservableObject {
57 57
         return removed.count
58 58
     }
59 59
 
60
+    @discardableResult
61
+    func removeAllInstances() -> Int {
62
+        let instances = loadInstances()
63
+        guard !instances.isEmpty else { return 0 }
64
+        for instance in instances {
65
+            if let panel = windowsByInstanceID.removeValue(forKey: instance.id) {
66
+                panel.close()
67
+            }
68
+        }
69
+        saveInstances([])
70
+        instancesChangeToken += 1
71
+        return instances.count
72
+    }
73
+
60 74
     func restore() {
61 75
         for instance in loadInstances() where windowsByInstanceID[instance.id] == nil {
62 76
             show(instance: instance)