-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50c6e94
commit 464ac75
Showing
1 changed file
with
39 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,35 +192,45 @@ export class ViewProvider implements WebviewViewProvider { | |
} | ||
case 'link-submit': { | ||
const { docId, code, url } = message.args; | ||
await vscode.window.withProgress( | ||
{ | ||
location: vscode.ProgressLocation.Notification, | ||
title: 'Connecting documentation with code', | ||
}, | ||
async () => { | ||
try { | ||
const authParams = await this.container.storage.getAuthParams(); | ||
const response = await axios.put( | ||
`${API_ENDPOINT}/links`, | ||
{ docId: docId, code: code, url: url }, | ||
{ | ||
params: authParams, | ||
}, | ||
); | ||
await this.prefillDoc(response.data.doc); | ||
await vscode.commands.executeCommand('mintlify.refresh-views'); | ||
await executeCommand(Commands.RefreshLinks); | ||
return vscode.window.showInformationMessage( | ||
`Successfully connected code with ${response.data.doc.title}`, | ||
); | ||
} catch (err) { | ||
const errMessage = | ||
err?.response?.data?.error ?? | ||
`Error connecting code. Please log back in, re-install the extension, or report bug to [email protected]`; | ||
return vscode.window.showInformationMessage(errMessage); | ||
} | ||
}, | ||
); | ||
try { | ||
const progress: string = await vscode.window.withProgress( | ||
{ | ||
location: vscode.ProgressLocation.Notification, | ||
title: 'Connecting documentation with code', | ||
}, | ||
() => { | ||
return new Promise((resolve, reject) => { | ||
this.container.storage | ||
.getAuthParams() | ||
.then(authParams => | ||
axios.put( | ||
`${API_ENDPOINT}/links`, | ||
{ docId: docId, code: code, url: url }, | ||
{ | ||
params: authParams, | ||
}, | ||
), | ||
) | ||
.then(response => { | ||
return this.prefillDoc(response.data.doc) | ||
.then(() => vscode.commands.executeCommand('mintlify.refresh-links')) | ||
.then(() => vscode.commands.executeCommand('mintlify.refresh-views')) | ||
.then(() => resolve(response.data.doc.title)); | ||
}) | ||
.catch(err => { | ||
const errMessage = | ||
err?.response?.data?.error ?? | ||
`Error connecting code. Please log back in, re-install the extension, or report bug to [email protected]`; | ||
return reject(errMessage); | ||
}); | ||
}); | ||
}, | ||
); | ||
await vscode.window.showInformationMessage(`Successfully connected code with ${progress}`); | ||
} catch (errMessage) { | ||
await vscode.window.showInformationMessage(errMessage); | ||
} | ||
|
||
break; | ||
} | ||
case 'refresh-code': { | ||
|