-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathcache.ts
More file actions
29 lines (27 loc) · 1.17 KB
/
cache.ts
File metadata and controls
29 lines (27 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* Copyright (c) 2025, Salesforce, Inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import {ApiClients, CacheUpdateMatrix} from '../types'
import {getSubscriptions} from './queryKeyHelpers'
import {CLIENT_KEYS} from '../../constant'
const CLIENT_KEY = CLIENT_KEYS.SHOPPER_CONSENTS
type Client = NonNullable<ApiClients[typeof CLIENT_KEY]>
export const cacheUpdateMatrix: CacheUpdateMatrix<Client> = {
updateSubscription(customerId, {parameters}, response) {
// When a subscription is updated, we invalidate the getSubscriptions query
// to ensure the UI reflects the latest subscription state
return {
invalidate: [{queryKey: getSubscriptions.queryKey(parameters)}]
}
},
updateSubscriptions(customerId, {parameters}, response) {
// When multiple subscriptions are updated, we invalidate the getSubscriptions query
// to ensure the UI reflects the latest subscription states
return {
invalidate: [{queryKey: getSubscriptions.queryKey(parameters)}]
}
}
}