mirror of
https://github.com/jeremyd/ergo.git
synced 2026-05-24 08:44:46 -07:00
fix buggy persistence of push timestamps
getPushSubscriptions() could have a stale view of the latest subscription renewal and successful push times. We don't want to rebuild on every renewal or every push, so add a boolean refresh argument that controls rebuilding.
This commit is contained in:
@@ -658,10 +658,17 @@ func (client *Client) hasPushSubscriptions() bool {
|
||||
return client.pushSubscriptionsExist.Load() != 0
|
||||
}
|
||||
|
||||
func (client *Client) getPushSubscriptions() []storedPushSubscription {
|
||||
func (client *Client) getPushSubscriptions(refresh bool) []storedPushSubscription {
|
||||
if refresh {
|
||||
func() {
|
||||
client.stateMutex.Lock()
|
||||
defer client.stateMutex.Unlock()
|
||||
client.rebuildPushSubscriptionCache()
|
||||
}()
|
||||
}
|
||||
|
||||
client.stateMutex.RLock()
|
||||
defer client.stateMutex.RUnlock()
|
||||
|
||||
return client.cachedPushSubscriptions
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user