|
1 | | -import type { QuickPickItem } from 'vscode'; |
| 1 | +import type { QuickPickItem, SecretStorageChangeEvent } from 'vscode'; |
2 | 2 | import { Disposable, env, EventEmitter, ProgressLocation, Range, Uri, window, workspace } from 'vscode'; |
3 | 3 | import type { OpenCloudPatchCommandArgs } from '../../commands/patches'; |
4 | 4 | import type { StoredDeepLinkContext, StoredNamedRef } from '../../constants.storage'; |
@@ -74,8 +74,12 @@ export class DeepLinkService implements Disposable { |
74 | 74 | container.uri.onDidReceiveUri(async (uri: Uri) => this.processDeepLinkUri(uri)), |
75 | 75 | ); |
76 | 76 |
|
77 | | - const pendingDeepLink = this.container.storage.get('deepLinks:pending'); |
78 | | - void this.processPendingDeepLink(pendingDeepLink); |
| 77 | + void this.container.storage.getSecret('deepLinks:pending').then(pendingDeepLink => { |
| 78 | + if (pendingDeepLink != null) { |
| 79 | + const link = JSON.parse(pendingDeepLink) as StoredDeepLinkContext; |
| 80 | + void this.processPendingDeepLink(link); |
| 81 | + } |
| 82 | + }); |
79 | 83 | } |
80 | 84 |
|
81 | 85 | dispose(): void { |
@@ -254,7 +258,7 @@ export class DeepLinkService implements Disposable { |
254 | 258 | @debug() |
255 | 259 | private async processPendingDeepLink(pendingDeepLink: StoredDeepLinkContext | undefined) { |
256 | 260 | if (pendingDeepLink == null) return; |
257 | | - void this.container.storage.delete('deepLinks:pending'); |
| 261 | + void this.container.storage.deleteSecret('deepLinks:pending'); |
258 | 262 | if (pendingDeepLink?.url == null) return; |
259 | 263 | const link = parseDeepLinkUri(Uri.parse(pendingDeepLink.url)); |
260 | 264 | if (link == null) return; |
@@ -1061,13 +1065,16 @@ export class DeepLinkService implements Disposable { |
1061 | 1065 | action = DeepLinkServiceAction.RepoOpening; |
1062 | 1066 | if (!(repoOpenLocation === 'addToWorkspace' && (workspace.workspaceFolders?.length || 0) > 1)) { |
1063 | 1067 | // Deep link will resolve in a different service instance |
1064 | | - await this.container.storage.store('deepLinks:pending', { |
1065 | | - url: this._context.url, |
1066 | | - repoPath: repoOpenUri.toString(), |
1067 | | - targetSha: this._context.targetSha, |
1068 | | - secondaryTargetSha: this._context.secondaryTargetSha, |
1069 | | - useProgress: useProgress, |
1070 | | - }); |
| 1068 | + await this.container.storage.storeSecret( |
| 1069 | + 'deepLinks:pending', |
| 1070 | + JSON.stringify({ |
| 1071 | + url: this._context.url, |
| 1072 | + repoPath: repoOpenUri.toString(), |
| 1073 | + targetSha: this._context.targetSha, |
| 1074 | + secondaryTargetSha: this._context.secondaryTargetSha, |
| 1075 | + useProgress: useProgress, |
| 1076 | + }), |
| 1077 | + ); |
1071 | 1078 | action = DeepLinkServiceAction.DeepLinkStored; |
1072 | 1079 | } |
1073 | 1080 |
|
@@ -1349,9 +1356,11 @@ export class DeepLinkService implements Disposable { |
1349 | 1356 |
|
1350 | 1357 | // Storing link info in case the switch causes a new window to open |
1351 | 1358 | const onWorkspaceChanging = async (isNewWorktree?: boolean) => |
1352 | | - this.container.storage.store( |
| 1359 | + this.container.storage.storeSecret( |
1353 | 1360 | 'deepLinks:pending', |
1354 | | - isNewWorktree ? pendingDeepLink : { ...pendingDeepLink, url: nonPrUrl }, |
| 1361 | + isNewWorktree |
| 1362 | + ? JSON.stringify(pendingDeepLink) |
| 1363 | + : JSON.stringify({ ...pendingDeepLink, url: nonPrUrl }), |
1355 | 1364 | ); |
1356 | 1365 |
|
1357 | 1366 | await executeGitCommand({ |
@@ -1406,7 +1415,7 @@ export class DeepLinkService implements Disposable { |
1406 | 1415 | } |
1407 | 1416 | case DeepLinkServiceState.OpenInspect: { |
1408 | 1417 | // If we arrive at this step, clear any stored data used for the "new window" option |
1409 | | - await this.container.storage.delete('deepLinks:pending'); |
| 1418 | + await this.container.storage.deleteSecret('deepLinks:pending'); |
1410 | 1419 | if (!repo) { |
1411 | 1420 | action = DeepLinkServiceAction.DeepLinkErrored; |
1412 | 1421 | message = 'Missing repository.'; |
|
0 commit comments