File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7575 },
7676 {
7777 "command" : " treeView.refreshList" ,
78- "title" : " Refresh! " ,
78+ "title" : " Refresh" ,
7979 "icon" : " src/icon/refresh.svg"
8080 }
8181 ],
8787 "group" : " navigation"
8888 }
8989 ]
90- }
90+ },
91+ "viewsWelcome" : [
92+ {
93+ "view" : " mdTreeItems" ,
94+ "contents" : " No notes found. Login first.\n [Login HackMD](command:HackMD.login)"
95+ }
96+ ]
9197 },
9298 "scripts" : {
9399 "vscode:prepublish" : " webpack --mode production" ,
Original file line number Diff line number Diff line change @@ -253,6 +253,8 @@ const login = async (context: vscode.ExtensionContext) => {
253253 }
254254 await API . login ( email , password ) ;
255255 if ( await checkLogin ( ) ) {
256+ store . isLogin = true ;
257+ context . globalState . update ( 'isLogin' , true ) ;
256258 vscode . window . showInformationMessage ( 'Successfully login!' ) ;
257259 } else {
258260 vscode . window . showInformationMessage ( 'Wrong email or password, please enter again' ) ;
@@ -313,6 +315,8 @@ export async function activate(context: vscode.ExtensionContext) {
313315 return ;
314316 }
315317 await API . logout ( ) ;
318+ store . isLogin = false ;
319+ context . globalState . update ( 'isLogin' , false ) ;
316320 vscode . window . showInformationMessage ( 'Successfully logged out.' ) ;
317321 await refreshHistoryList ( context ) ;
318322 } ) ) ;
Original file line number Diff line number Diff line change 11import * as vscode from 'vscode' ;
2- import { Store } from './store' ;
2+ import { Store , store } from './store' ;
33import { reaction } from 'mobx' ;
44// const history = (await API.getHistory()).history;
55export class MdTreeItemProvider implements vscode . TreeDataProvider < TreeNode > {
@@ -21,12 +21,14 @@ export class MdTreeItemProvider implements vscode.TreeDataProvider<TreeNode> {
2121 }
2222
2323 getChildren ( element ?: TreeNode ) : vscode . ProviderResult < TreeNode [ ] > {
24- if ( element === undefined ) {
25- return [ new TreeNode ( "history" , vscode . TreeItemCollapsibleState . Collapsed ) ]
26- } else {
27- return this . store . history . map ( item =>
28- new NoteTreeNode ( item . id , item . text , vscode . TreeItemCollapsibleState . None )
29- ) ;
24+ if ( store . isLogin ) {
25+ if ( element === undefined ) {
26+ return [ new TreeNode ( "history" , vscode . TreeItemCollapsibleState . Collapsed ) ]
27+ } else {
28+ return this . store . history . map ( item =>
29+ new NoteTreeNode ( item . id , item . text , vscode . TreeItemCollapsibleState . None )
30+ ) ;
31+ }
3032 }
3133 }
3234
Original file line number Diff line number Diff line change 11import { observable } from "mobx" ;
22
33export interface Store {
4- history : Array < any >
4+ history : Array < any > ;
5+ isLogin : boolean ;
56}
67
78export const store : Store = observable ( {
8- history : [ { } ]
9+ history : [ { } ] ,
10+ isLogin : false
911} ) ;
You can’t perform that action at this time.
0 commit comments