diff --git a/extension/src/webview/contract.ts b/extension/src/webview/contract.ts index 782e9a3695..b4f2737320 100644 --- a/extension/src/webview/contract.ts +++ b/extension/src/webview/contract.ts @@ -211,7 +211,3 @@ export type MessageToWebview = { export enum MessageToWebviewType { SET_DATA = 'setData' } - -export interface WebviewState { - dvcRoot: string -} diff --git a/extension/src/webview/factory.ts b/extension/src/webview/factory.ts index 7c8f35f1a9..dd74e4235e 100644 --- a/extension/src/webview/factory.ts +++ b/extension/src/webview/factory.ts @@ -1,19 +1,20 @@ import { Uri, ViewColumn, WebviewPanel, window } from 'vscode' import { BaseWebview } from '.' import { ViewKey, WebviewDetails } from './constants' -import { WebviewState, WebviewData } from './contract' import { Resource } from '../resourceLocator' import { getWorkspaceRootUris } from '../vscode/workspaceFolders' -export const isValidDvcRoot = (dvcRoot?: string): dvcRoot is string => !!dvcRoot +const isValidDvcRoot = (dvcRoot?: string): dvcRoot is string => !!dvcRoot + +const needsDvcRoot = (viewKey: ViewKey): boolean => + ![ViewKey.CONNECT, ViewKey.SETUP].includes(viewKey) const create = ( viewKey: ViewKey, webviewPanel: WebviewPanel, - dvcRoot: string, - bypassDvcRoot?: boolean + dvcRoot: string ) => { - if (!bypassDvcRoot && !isValidDvcRoot(dvcRoot)) { + if (needsDvcRoot(viewKey) && !isValidDvcRoot(dvcRoot)) { throw new Error(`trying to set invalid state into ${viewKey}`) } @@ -26,8 +27,7 @@ export const createWebview = async ( viewKey: ViewKey, dvcRoot: string, iconPath: Resource, - viewColumn?: ViewColumn, - bypassDvcRoot?: boolean + viewColumn?: ViewColumn ) => { const { title, distPath } = WebviewDetails[viewKey] @@ -44,21 +44,7 @@ export const createWebview = async ( webviewPanel.iconPath = iconPath - const view = create(viewKey, webviewPanel, dvcRoot, bypassDvcRoot) + const view = create(viewKey, webviewPanel, dvcRoot) await view.isReady() return view } - -export const restoreWebview = ( - viewKey: ViewKey, - webviewPanel: WebviewPanel, - state: WebviewState -): Promise> => { - return new Promise((resolve, reject) => { - try { - resolve(create(viewKey, webviewPanel, state.dvcRoot)) - } catch (error: unknown) { - reject(error) - } - }) -} diff --git a/extension/src/webview/repository.ts b/extension/src/webview/repository.ts index 2cb8349e04..ac0019ffb6 100644 --- a/extension/src/webview/repository.ts +++ b/extension/src/webview/repository.ts @@ -47,8 +47,7 @@ export abstract class BaseRepository< this.viewKey, this.dvcRoot, this.webviewIcon, - viewColumn, - [ViewKey.CONNECT, ViewKey.SETUP].includes(this.viewKey) + viewColumn ) this.setWebview(webview)