@@ -59,7 +59,10 @@ const DICTIONARY_LOADING_FAILED_MESSAGE =
59
59
"syntax. Please fix it. Apologies for the inconvenience." ;
60
60
const NO_WORD_MESSAGE = "Please provide a word" ;
61
61
const WORD_NOT_FOUND_MESSAGE = "Word not found" ;
62
- const DICTIONARY_ERROR_MESSAGE = "Please fix the errors before saving" ;
62
+ const WORD_ALREADY_IMPORTED_MESSAGE = "The word is already imported" ;
63
+ const DICTIONARY_ERROR_MESSAGE_ON_IMPORT =
64
+ "Please fix the errors before adding words" ;
65
+ const DICTIONARY_ERROR_MESSAGE_ON_SAVE = "Please fix the errors before saving" ;
63
66
64
67
function main ( ) : void {
65
68
// load elements
@@ -296,6 +299,12 @@ function main(): void {
296
299
const word = importWordTextBox . value . trim ( ) ;
297
300
if ( word === "" ) {
298
301
showMessage ( NO_WORD_MESSAGE ) ;
302
+ } else if ( currentDictionary . isError ( ) ) {
303
+ showMessage ( WORD_ALREADY_IMPORTED_MESSAGE ) ;
304
+ } else if (
305
+ currentDictionary . unwrap ( ) [ 0 ] . has ( word )
306
+ ) {
307
+ showMessage ( DICTIONARY_ERROR_MESSAGE_ON_IMPORT ) ;
299
308
} else {
300
309
const definitions = dictionary . get ( word ) ?. source ;
301
310
if ( definitions != null ) {
@@ -307,6 +316,7 @@ function main(): void {
307
316
0 ,
308
317
customDictionaryTextBox . scrollHeight ,
309
318
) ;
319
+ updateDictionary ( ) ;
310
320
} else {
311
321
showMessage ( WORD_NOT_FOUND_MESSAGE ) ;
312
322
}
@@ -344,7 +354,7 @@ function main(): void {
344
354
setIgnoreError ( DICTIONARY_KEY , customDictionaryTextBox . value ) ;
345
355
customDictionaryDialogBox . close ( ) ;
346
356
} else {
347
- showMessage ( DICTIONARY_ERROR_MESSAGE ) ;
357
+ showMessage ( DICTIONARY_ERROR_MESSAGE_ON_SAVE ) ;
348
358
}
349
359
}
350
360
closeButton . addEventListener ( "click" , ( ) => {
0 commit comments