Skip to content
Snippets Groups Projects
Commit 0c0383b3 authored by Lansana DIOMANDE's avatar Lansana DIOMANDE
Browse files

refactor: remove all '_' on private function and attribut

parent 0d1c2826
Branches
Tags
2 merge requests!16feat: publish extension on marketplace with ci,!15feat(Sprint1): add authentication + directory picking + redirection link
......@@ -49,11 +49,11 @@ export default class ExtensionStore {
}
public async getAccessToken() {
return this._readSecret(StoreKey.AccessTokenKey);
return this.readSecret(StoreKey.AccessTokenKey);
}
public async getRefreshToken() {
return this._readSecret(StoreKey.RefreshTokenKey);
return this.readSecret(StoreKey.RefreshTokenKey);
}
public async setAccessToken(accessToken: string) {
......@@ -61,7 +61,7 @@ export default class ExtensionStore {
log('Attempt to store undefined access token');
return;
}
return this._storeSecret(StoreKey.AccessTokenKey, accessToken);
return this.storeSecret(StoreKey.AccessTokenKey, accessToken);
}
public async setRefreshToken(refreshToken: string) {
......@@ -69,14 +69,14 @@ export default class ExtensionStore {
log('Attempt to store undefined refresh token');
return;
}
return this._storeSecret(StoreKey.RefreshTokenKey, refreshToken);
return this.storeSecret(StoreKey.RefreshTokenKey, refreshToken);
}
private async _storeSecret(key: StoreKey, value: string) {
private async storeSecret(key: StoreKey, value: string) {
this.secretStorage.store(key, value);
}
private async _readSecret(key: StoreKey) {
private async readSecret(key: StoreKey) {
return this.secretStorage.get(key);
}
}
......
import { Command as VscodeComand } from 'vscode';
export class Command {
constructor(private _title: string, private _command: string) {}
constructor(private _title: string, private command: string) {}
get title() {
return this._title;
}
get cmd() {
return this._command;
return this.command;
}
asVsCodeCommand(): VscodeComand {
......
......@@ -25,8 +25,8 @@ export function getUri(webview: Webview, extensionUri: Uri, pathList: string[])
export abstract class WebviewBase implements Disposable {
protected disposable: Disposable;
private _disposablePanel: Disposable | undefined;
protected _panel: WebviewPanel | undefined;
private disposablePanel: Disposable | undefined;
protected panel: WebviewPanel | undefined;
constructor(private id: string, private title: string, command: Command, private readonly _column?: ViewColumn) {
this.disposable = Disposable.from(commands.registerCommand(command.cmd, this.onShowCommand, this));
......@@ -34,7 +34,7 @@ export abstract class WebviewBase implements Disposable {
}
getExternalRessourcePath(extensionUri: Uri, pathList: string[]) {
return getUri(this._panel!.webview, extensionUri, pathList);
return getUri(this.panel!.webview, extensionUri, pathList);
}
registerCommands(): Disposable[] {
......@@ -47,7 +47,7 @@ export abstract class WebviewBase implements Disposable {
dispose() {
this.disposable.dispose();
this._disposablePanel?.dispose();
this.disposablePanel?.dispose();
}
protected onShowCommand() {
......@@ -55,8 +55,8 @@ export abstract class WebviewBase implements Disposable {
}
private onPanelDisposed() {
this._disposablePanel?.dispose();
this._panel = undefined;
this.disposablePanel?.dispose();
this.panel = undefined;
}
private onViewStateChanged(e: WebviewPanelOnDidChangeViewStateEvent) {
......@@ -67,17 +67,17 @@ export abstract class WebviewBase implements Disposable {
}
get visible() {
return this._panel?.visible ?? false;
return this.panel?.visible ?? false;
}
hide() {
this._panel?.dispose();
this.panel?.dispose();
}
setTitle(title: string) {
if (this._panel == null) return;
if (this.panel == null) return;
this._panel.title = title;
this.panel.title = title;
}
onMessageReceive(message) {
......@@ -89,8 +89,8 @@ export abstract class WebviewBase implements Disposable {
}
async show(column: ViewColumn = ViewColumn.Beside): Promise<void> {
if (this._panel == null) {
this._panel = window.createWebviewPanel(
if (this.panel == null) {
this.panel = window.createWebviewPanel(
this.id,
this.title,
{ viewColumn: column, preserveFocus: false },
......@@ -102,33 +102,33 @@ export abstract class WebviewBase implements Disposable {
},
);
this._disposablePanel = Disposable.from(
this._panel,
this._panel.onDidDispose(this.onPanelDisposed, this),
this._panel.onDidChangeViewState(this.onViewStateChanged, this),
this._panel.webview.onDidReceiveMessage(this.onMessageReceive, this),
this.disposablePanel = Disposable.from(
this.panel,
this.panel.onDidDispose(this.onPanelDisposed, this),
this.panel.onDidChangeViewState(this.onViewStateChanged, this),
this.panel.webview.onDidReceiveMessage(this.onMessageReceive, this),
...this.registerCommands(),
);
this._panel.webview.html = await this.getHtml(this._panel.webview);
this.panel.webview.html = await this.getHtml(this.panel.webview);
} else {
const html = await this.getHtml(this._panel.webview);
const html = await this.getHtml(this.panel.webview);
// Reset the html to get the webview to reload
this._panel.webview.html = '';
this._panel.webview.html = html;
this.panel.webview.html = '';
this.panel.webview.html = html;
this._panel.reveal(this._panel.viewColumn ?? ViewColumn.Active, false);
this.panel.reveal(this.panel.viewColumn ?? ViewColumn.Active, false);
}
}
async reload() {
if (this._panel) {
const html = await this.getHtml(this._panel.webview);
if (this.panel) {
const html = await this.getHtml(this.panel.webview);
// Reset the html to get the webview to reload
this._panel.webview.html = '';
this._panel.webview.html = html;
this.panel.webview.html = '';
this.panel.webview.html = html;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment