1
- import { normalizePath , moment , Notice , TFolder , Setting } from "obsidian" ;
1
+ import { normalizePath , Notice , TFolder , Setting , moment } from "obsidian" ;
2
2
import { EncryptedFileContentView , VIEW_TYPE_ENCRYPTED_FILE_CONTENT } from "./EncryptedFileContentView" ;
3
3
import { IMeldEncryptPluginFeature } from "../IMeldEncryptPluginFeature" ;
4
4
import MeldEncrypt from "../../main" ;
5
5
import { IMeldEncryptPluginSettings } from "../../settings/MeldEncryptPluginSettings" ;
6
6
import { IFeatureWholeNoteEncryptSettings } from "./IFeatureWholeNoteEncryptSettings" ;
7
- import { UiHelper } from "../../services/UiHelper" ;
8
7
9
8
export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeature {
10
9
@@ -29,7 +28,7 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur
29
28
id : 'meld-encrypt-create-new-note' ,
30
29
name : 'Create new encrypted note' ,
31
30
icon : 'lock' ,
32
- checkCallback : ( checking ) => this . processCreateNewEncryptedNoteCommand ( checking )
31
+ callback : ( ) => this . processCreateNewEncryptedNoteCommand ( ) ,
33
32
} ) ;
34
33
35
34
}
@@ -38,14 +37,9 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur
38
37
this . plugin . app . workspace . detachLeavesOfType ( VIEW_TYPE_ENCRYPTED_FILE_CONTENT ) ;
39
38
}
40
39
41
- private processCreateNewEncryptedNoteCommand ( checking : boolean ) : boolean {
42
- //console.debug('processCreateNewEncryptedNoteCommand', {checking});
40
+ private processCreateNewEncryptedNoteCommand ( ) : boolean {
43
41
try {
44
- if ( checking || UiHelper . isSettingsModalOpen ( ) ) {
45
- return true ;
46
- }
47
-
48
- const newFilename = moment ( ) . format ( '[Untitled] YYYYMMDD hhmmss[.encrypted]' ) ;
42
+ const newFilename = moment ( ) . format ( '[Untitled] YYYYMMDD hhmmss[.encrypted]' ) ;
49
43
50
44
let newFileFolder : TFolder ;
51
45
const activeFile = this . plugin . app . workspace . getActiveFile ( ) ;
@@ -59,9 +53,9 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur
59
53
const newFilepath = normalizePath ( newFileFolder . path + "/" + newFilename ) ;
60
54
//console.debug('processCreateNewEncryptedNoteCommand', {newFilepath});
61
55
62
- this . plugin . app . vault . create ( newFilepath , '' ) . then ( f => {
56
+ this . plugin . app . vault . create ( newFilepath , '' ) . then ( async f => {
63
57
const leaf = this . plugin . app . workspace . getLeaf ( false ) ;
64
- leaf . openFile ( f ) ;
58
+ await leaf . openFile ( f ) ;
65
59
} ) . catch ( reason => {
66
60
new Notice ( reason , 10000 ) ;
67
61
} ) ;
@@ -109,7 +103,7 @@ export default class FeatureWholeNoteEncrypt implements IMeldEncryptPluginFeatur
109
103
// turn on ribbon icon
110
104
if ( this . ribbonIconCreateNewNote == null ) {
111
105
this . ribbonIconCreateNewNote = this . plugin . addRibbonIcon ( 'lock' , 'Create new encrypted note' , ( ev ) => {
112
- this . processCreateNewEncryptedNoteCommand ( false ) ;
106
+ this . processCreateNewEncryptedNoteCommand ( ) ;
113
107
} ) ;
114
108
}
115
109
} else {
0 commit comments