ruby_everywhere 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: effe761f70b4c3220e02788d26a8fc49278a52f3e3876c331e3f9f484867592f
4
- data.tar.gz: 9e589059bea3245ad9540696a24edfb9261736e0d1f30467698aad051c78541e
3
+ metadata.gz: 500e5331ac0f9b650cef020b9992c4f54bcff2ec08a37aa160da69c57468498a
4
+ data.tar.gz: 78114f8b44040ad51a3d2e10b033f6e6df25f46ee0a91cfbd96e519987ae52fc
5
5
  SHA512:
6
- metadata.gz: ca496e477bd712bc8a8687916f8f9c17e1a3736d944f245bd633812a479d7771e1457107dd3e7135a2536657e70c4a5aecebe6a5c3df5ee5d12428fe70b423ba
7
- data.tar.gz: 28e6a3a1c4a6c6c90a455ad545354a1d6812ea3bd1c3ef57a6a1d252c7e7ddf30d5edf7375a7b99e53dd15e6e059c70b11c55ef7070f2df90906b9ca2b13f36b
6
+ metadata.gz: ecd03c6b0ee4823567da935d34696fa75925472b9e2cfb086cb8e00b80cc2e74b72d89c94b588ce807187a511fa12e2b4ce385105befd0e3fbd2f520efaadce1
7
+ data.tar.gz: 683c8c90f049d8a7ae8718ad4ca12d4a02c7acfe639c01b76b38bcf9d7507ff37dfd7a7bf81ac6381dc1f990245f78ae83a2a99f6c1227488e2cc0105c58b6fb
@@ -3,7 +3,7 @@
3
3
  require "json"
4
4
 
5
5
  module Everywhere
6
- VERSION = "0.10.0"
6
+ VERSION = "0.10.1"
7
7
 
8
8
  # Version of the @rubyeverywhere/bridge JS this gem ships. bridge/ in the
9
9
  # gem IS the npm package (served to Rails apps by Everywhere::Engine,
@@ -122,7 +122,7 @@ final class WebControlHandler: NSObject, WKScriptMessageHandler {
122
122
  let info = (body["to"] as? String).map { ["to": $0] }
123
123
  NotificationCenter.default.post(name: .everywhereResetApp, object: nil, userInfo: info)
124
124
  case "setBadge":
125
- setAppBadge((body["count"] as? NSNumber)?.intValue ?? 0)
125
+ AppIconBadge.set((body["count"] as? NSNumber)?.intValue ?? 0)
126
126
  case "setTabBadge":
127
127
  guard let path = body["path"] as? String else { return }
128
128
  NotificationCenter.default.post(
@@ -143,9 +143,13 @@ final class WebControlHandler: NSObject, WKScriptMessageHandler {
143
143
  break
144
144
  }
145
145
  }
146
+ }
146
147
 
148
+ /// The app icon badge. Set by the page through `setBadge`, and cleared by the
149
+ /// scene on every reset — see `SceneDelegate.clearBadges()`.
150
+ enum AppIconBadge {
147
151
  /// Provisional authorization is silent — no permission prompt for a badge.
148
- private func setAppBadge(_ count: Int) {
152
+ static func set(_ count: Int) {
149
153
  let center = UNUserNotificationCenter.current()
150
154
  center.requestAuthorization(options: [.badge, .provisional]) { granted, _ in
151
155
  guard granted else { return }
@@ -204,6 +204,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
204
204
  authFlow.cancel()
205
205
  awaitingAuthHandoff = false
206
206
  clearWebContentCache()
207
+ clearBadges()
207
208
  rebuildRoot(entries: [], routeTo: target)
208
209
  loadedTabsFingerprint = "" // matches the empty tab set we just built
209
210
  loadPathConfiguration(serverOnly: true)
@@ -272,6 +273,7 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
272
273
  guard let handoff = config.authHandoffURL(token: token) else { return }
273
274
 
274
275
  clearWebContentCache()
276
+ clearBadges()
275
277
  rebuildRoot(entries: [], routeTo: handoff)
276
278
  loadedTabsFingerprint = "" // matches the empty tab set we just built
277
279
  awaitingAuthHandoff = true
@@ -465,6 +467,21 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
465
467
  applyTabBadge(path: path, value: count > 0 ? String(count) : nil)
466
468
  }
467
469
 
470
+ /// Drop every badge the app is carrying. Called from the reset sequence,
471
+ /// alongside the web content cache and for the same reason: a count belongs
472
+ /// to the session and the instance that rendered it, and a reset means one
473
+ /// of those is gone — a sign-out, a sign-in as someone else, or leaving a
474
+ /// picked instance for the picker. Without this the previous user's counts
475
+ /// stay on the app icon (nothing ever posts setBadge again once they're
476
+ /// signed out) and ride the stored `tabBadges` back onto the next tab bar
477
+ /// `rebuildRoot` builds. Whatever lands after the reset re-renders its own
478
+ /// `everywhere_badge` / `everywhere_tab_badge` metas if it has any.
479
+ private func clearBadges() {
480
+ tabBadges.keys.forEach { applyTabBadge(path: $0, value: nil) }
481
+ tabBadges.removeAll()
482
+ AppIconBadge.set(0)
483
+ }
484
+
468
485
  private func applyTabBadge(path: String, value: String?) {
469
486
  if #available(iOS 18.0, *), let tabBarController {
470
487
  tabBarController.tabs.first { $0.identifier == path }?.badgeValue = value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_everywhere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Fomera