File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 1
1
import * as vscode from 'vscode' ;
2
2
import { API } from './../api' ;
3
+ import { checkLogin } from './../utils' ;
3
4
4
5
export function registerSnippetCommands ( context : vscode . ExtensionContext ) {
5
6
context . subscriptions . push ( vscode . commands . registerCommand ( 'HackMD.createCodeSnippet' , async ( ) => {
7
+ if ( ! ( await checkLogin ( ) ) ) {
8
+ vscode . window . showInformationMessage ( 'Please login first.' ) ;
9
+ return ;
10
+ }
11
+
6
12
const editor = vscode . window . activeTextEditor ;
7
13
if ( editor . selection . isEmpty ) {
8
14
vscode . window . showInformationMessage ( 'The code block is empty. Please select a range of text first.' ) ;
Original file line number Diff line number Diff line change
1
+ import { API } from './api' ;
2
+
3
+ export const checkLogin = async ( ) => {
4
+ return ( await API . getMe ( ) ) . status === 'ok' ;
5
+ } ;
You can’t perform that action at this time.
0 commit comments