refactor: extract the methods about user into class User
This commit is contained in:
28
src/user.ts
Normal file
28
src/user.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export default class User {
|
||||
private context:vscode.ExtensionContext;
|
||||
private usernameKey:string = 'devstarUsername'
|
||||
private userTokenKey:string = 'devstarUserToken'
|
||||
|
||||
constructor(context: vscode.ExtensionContext) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public getUsernameFromLocal(): string|undefined {
|
||||
return this.context.globalState.get(this.usernameKey);
|
||||
}
|
||||
|
||||
public getUserTokenFromLocal(): string|undefined{
|
||||
return this.context.globalState.get(this.userTokenKey);
|
||||
}
|
||||
|
||||
public setUsernameToLocal(username:string) {
|
||||
this.context.globalState.update(this.usernameKey, username)
|
||||
}
|
||||
|
||||
public setUserTokenToLocal(userToken:string) {
|
||||
this.context.globalState.update(this.userTokenKey, userToken)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user