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 11import * as vscode from 'vscode' ;
22import { API } from './../api' ;
3+ import { checkLogin } from './../utils' ;
34
45export function registerSnippetCommands ( context : vscode . ExtensionContext ) {
56 context . subscriptions . push ( vscode . commands . registerCommand ( 'HackMD.createCodeSnippet' , async ( ) => {
7+ if ( ! ( await checkLogin ( ) ) ) {
8+ vscode . window . showInformationMessage ( 'Please login first.' ) ;
9+ return ;
10+ }
11+
612 const editor = vscode . window . activeTextEditor ;
713 if ( editor . selection . isEmpty ) {
814 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