File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed
Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,14 @@ function popupHandler(port) {
7373 toggleBehaviors ( tabId ) ;
7474 break ;
7575
76- case "newColl" :
77- collLoader . initNewColl ( { title : message . title } ) . then ( async ( newColl ) => {
78- defaultCollId = newColl . name ;
79- await setLocalOption ( "defaultCollId" , defaultCollId ) ;
80- port . postMessage ( await listAllMsg ( collLoader ) ) ;
81- } ) ;
76+ case "newColl" : {
77+ const { name } = await collLoader . initNewColl ( { title : message . title } ) ;
78+ defaultCollId = name ;
79+ port . postMessage ( await listAllMsg ( collLoader , { defaultCollId} ) ) ;
80+ await setLocalOption ( "defaultCollId" , defaultCollId ) ;
8281 break ;
8382 }
83+ }
8484 } ) ;
8585
8686 port . onDisconnect . addListener ( ( ) => {
Original file line number Diff line number Diff line change @@ -623,15 +623,15 @@ class RecPopup extends LitElement
623623 event . preventDefault ( ) ;
624624 }
625625
626- async onNewColl ( ) {
627- await removeLocalOption ( ` ${ this . tabId } -collId` ) ;
626+ onNewColl ( ) {
627+ const title = this . renderRoot . querySelector ( "#new-name" ) . value ;
628628
629629 this . sendMessage ( {
630630 tabId : this . tabId ,
631631 type : "newColl" ,
632- title : this . renderRoot . querySelector ( "#new-name" ) . value
632+ title
633633 } ) ;
634-
634+ removeLocalOption ( ` ${ this . tabId } -collId` ) ;
635635 this . collDrop = "" ;
636636 }
637637}
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ export async function ensureDefaultColl(collLoader)
3131}
3232
3333// ===========================================================================
34- export async function listAllMsg ( collLoader ) {
34+ export async function listAllMsg ( collLoader , { defaultCollId = null } = { } ) {
3535 let colls = await ensureDefaultColl ( collLoader ) ;
3636
3737 colls = colls . map ( x => getCollData ( x ) ) ;
@@ -49,7 +49,7 @@ export async function listAllMsg(collLoader) {
4949 } ) ;
5050
5151 const msg = { type : "collections" } ;
52- msg . collId = await getLocalOption ( "defaultCollId" ) ;
52+ msg . collId = defaultCollId || await getLocalOption ( "defaultCollId" ) ;
5353 msg . collections = colls . map ( coll => ( {
5454 id : coll . id ,
5555 title : coll . title || coll . filename
You can’t perform that action at this time.
0 commit comments