@@ -22,20 +22,12 @@ interface Food {
2222export class AppComponent {
2323 title = 'LeetcodeSessionManager' ;
2424
25- foods : Food [ ] = [
26- { value : 'steak-0' , viewValue : 'Steak' } ,
27- { value : 'pizza-1' , viewValue : 'Pizza' } ,
28- { value : 'tacos-2' , viewValue : 'Tacos' } ,
29- ] ;
30-
3125 leetcodeSessions : Session [ ] = [ ] ;
3226
3327 currentChosenSession : Session | undefined = undefined ;
3428 isLoading : boolean = false ;
3529
36- private _dialogRef : any ;
3730 constructor (
38- private formBuilder : FormBuilder ,
3931 private _appService : SrcService ,
4032 private cdRef : ChangeDetectorRef ,
4133 private _snackBarService : SnackbarService ,
@@ -80,9 +72,17 @@ export class AppComponent {
8072 */
8173 async changeCurrentUserSession ( session : Session ) {
8274 this . currentChosenSession = session ;
75+
76+ if ( this . currentChosenSession !== undefined ) {
77+ if ( this . currentChosenSession . name === "" ) {
78+ this . currentChosenSession . name = "Anonymous Session" ;
79+ }
80+ }
8381 // send message to background to store to local storage
82+ console . log ( 'current_session' , this . currentChosenSession ) ;
83+
8484 chrome . runtime . sendMessage ( {
85- current_session : session ,
85+ current_session : this . currentChosenSession ,
8686 } ) ;
8787 }
8888
@@ -104,7 +104,9 @@ export class AppComponent {
104104 } else {
105105 this . isLoading = false ;
106106 console . debug ( 'Fetched sessions: ' , sessions ) ;
107- this . leetcodeSessions = sessions ;
107+ this . leetcodeSessions = sessions . map ( session => ( {
108+ ...session , name : session . name === "" ? "Anonymous Session" : session . name
109+ } ) ) ;
108110 chrome . runtime . sendMessage ( {
109111 sessions : this . leetcodeSessions ,
110112 } ) ;
0 commit comments