@@ -22,20 +22,12 @@ interface Food {
22
22
export class AppComponent {
23
23
title = 'LeetcodeSessionManager' ;
24
24
25
- foods : Food [ ] = [
26
- { value : 'steak-0' , viewValue : 'Steak' } ,
27
- { value : 'pizza-1' , viewValue : 'Pizza' } ,
28
- { value : 'tacos-2' , viewValue : 'Tacos' } ,
29
- ] ;
30
-
31
25
leetcodeSessions : Session [ ] = [ ] ;
32
26
33
27
currentChosenSession : Session | undefined = undefined ;
34
28
isLoading : boolean = false ;
35
29
36
- private _dialogRef : any ;
37
30
constructor (
38
- private formBuilder : FormBuilder ,
39
31
private _appService : SrcService ,
40
32
private cdRef : ChangeDetectorRef ,
41
33
private _snackBarService : SnackbarService ,
@@ -80,9 +72,17 @@ export class AppComponent {
80
72
*/
81
73
async changeCurrentUserSession ( session : Session ) {
82
74
this . currentChosenSession = session ;
75
+
76
+ if ( this . currentChosenSession !== undefined ) {
77
+ if ( this . currentChosenSession . name === "" ) {
78
+ this . currentChosenSession . name = "Anonymous Session" ;
79
+ }
80
+ }
83
81
// send message to background to store to local storage
82
+ console . log ( 'current_session' , this . currentChosenSession ) ;
83
+
84
84
chrome . runtime . sendMessage ( {
85
- current_session : session ,
85
+ current_session : this . currentChosenSession ,
86
86
} ) ;
87
87
}
88
88
@@ -104,7 +104,9 @@ export class AppComponent {
104
104
} else {
105
105
this . isLoading = false ;
106
106
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
+ } ) ) ;
108
110
chrome . runtime . sendMessage ( {
109
111
sessions : this . leetcodeSessions ,
110
112
} ) ;
0 commit comments