( groveEnabled: boolean, )
| 138 | * Update Grove settings for the user account |
| 139 | */ |
| 140 | export async function updateGroveSettings( |
| 141 | groveEnabled: boolean, |
| 142 | ): Promise<void> { |
| 143 | try { |
| 144 | await withOAuth401Retry(() => { |
| 145 | const authHeaders = getAuthHeaders() |
| 146 | if (authHeaders.error) { |
| 147 | throw new Error(`Failed to get auth headers: ${authHeaders.error}`) |
| 148 | } |
| 149 | return axios.patch( |
| 150 | buildNoumenaPlatformUrl('/api/oauth/account/settings'), |
| 151 | { |
| 152 | grove_enabled: groveEnabled, |
| 153 | }, |
| 154 | { |
| 155 | headers: { |
| 156 | ...authHeaders.headers, |
| 157 | 'User-Agent': getNcodeUserAgent(), |
| 158 | }, |
| 159 | }, |
| 160 | ) |
| 161 | }) |
| 162 | // Invalidate memoized settings so the post-toggle confirmation |
| 163 | // read in privacy-settings.tsx picks up the new value. |
| 164 | getGroveSettings.cache.clear?.() |
| 165 | } catch (err) { |
| 166 | logError(err) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Check if user is qualified for Grove (non-blocking, cache-first). |
no test coverage detected