refactor(User): set user name and user token as member variable
This commit is contained in:
14
src/user.ts
14
src/user.ts
@@ -1,28 +1,36 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as os from 'os';
|
||||||
|
|
||||||
export default class User {
|
export default class User {
|
||||||
private context:vscode.ExtensionContext;
|
private context:vscode.ExtensionContext;
|
||||||
|
private username:string|undefined;
|
||||||
|
private userToken:string|undefined;
|
||||||
private usernameKey:string = 'devstarUsername'
|
private usernameKey:string = 'devstarUsername'
|
||||||
private userTokenKey:string = 'devstarUserToken'
|
private userTokenKey:string = 'devstarUserToken'
|
||||||
|
|
||||||
constructor(context: vscode.ExtensionContext) {
|
constructor(context: vscode.ExtensionContext) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.username = this.context.globalState.get(this.usernameKey);
|
||||||
|
this.userToken = this.context.globalState.get(this.userTokenKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUsernameFromLocal(): string|undefined {
|
public getUsernameFromLocal(): string|undefined {
|
||||||
return this.context.globalState.get(this.usernameKey);
|
return this.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUserTokenFromLocal(): string|undefined{
|
public getUserTokenFromLocal(): string|undefined{
|
||||||
return this.context.globalState.get(this.userTokenKey);
|
return this.userToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setUsernameToLocal(username:string) {
|
public setUsernameToLocal(username:string) {
|
||||||
this.context.globalState.update(this.usernameKey, username)
|
this.context.globalState.update(this.usernameKey, username);
|
||||||
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setUserTokenToLocal(userToken:string) {
|
public setUserTokenToLocal(userToken:string) {
|
||||||
this.context.globalState.update(this.userTokenKey, userToken)
|
this.context.globalState.update(this.userTokenKey, userToken)
|
||||||
|
this.userToken = userToken
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user