File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -622,16 +622,29 @@ document.addEventListener("alpine:init", () => {
622622 this . subsSelMiddle = [ ] ;
623623 this . subsSelRight = [ ] ;
624624 this . subsError = "" ;
625- // Load current subscription from localStorage (last-saved secret state).
626- // The ``courses`` table is NOT a valid fallback — it holds every course
627- // that has ever been processed, not just the currently subscribed ones.
625+ // Load subscription from localStorage (cached secret state).
628626 this . subscribedIds = [ ] ;
629627 try {
630628 var cached = JSON . parse (
631629 localStorage . getItem ( _LS + "lastSubscribed" ) || "null"
632630 ) ;
633631 if ( Array . isArray ( cached ) ) this . subscribedIds = cached . map ( String ) ;
634632 } catch { }
633+ // One-time migration: if the cache is empty, seed it from the courses
634+ // table so the user doesn't start with an empty left column. Save
635+ // immediately so future loads read from localStorage without the DB
636+ // fallback (the courses table grows over time and isn't the secret).
637+ if ( ! this . subscribedIds . length ) {
638+ this . subscribedIds = ICS . db . getSubscribedCourseIds ( ) . map ( String ) ;
639+ if ( this . subscribedIds . length ) {
640+ try {
641+ localStorage . setItem (
642+ _LS + "lastSubscribed" ,
643+ JSON . stringify ( this . subscribedIds ) ,
644+ ) ;
645+ } catch { }
646+ }
647+ }
635648 this . rebuildSubsFiltered ( ) ;
636649 this . navigate ( "subscriptions" ) ;
637650 } ,
You can’t perform that action at this time.
0 commit comments