File tree Expand file tree Collapse file tree 4 files changed +21
-22
lines changed
Expand file tree Collapse file tree 4 files changed +21
-22
lines changed Original file line number Diff line number Diff line change @@ -11,31 +11,29 @@ const PATH_USER_DEFAULT_IMAGE: string = '/usr/share/codam/web-greeter/user.png';
1111
1212export class GreeterImage {
1313 private _path : string ;
14- private _exists : boolean = false ;
14+ private _exists : boolean | null = null ;
1515
1616 public constructor ( path : string ) {
1717 this . _path = path ;
18+ }
1819
19- // Check if file exists
20+ public async exists ( ) : Promise < boolean > {
21+ if ( this . _exists !== null ) {
22+ return this . _exists ;
23+ }
2024 const dir = this . _path . split ( '/' ) . slice ( 0 , - 1 ) . join ( '/' ) ;
2125 const self = this ;
22- window . theme_utils ?. dirlist ( dir , false , ( dirFiles : string [ ] | undefined ) => {
23- self . _exists = ( dirFiles !== undefined && dirFiles . includes ( self . _path ) ) ;
24- if ( ! self . _exists ) {
25- console . warn ( 'Image file does not exist: ' + self . _path ) ;
26- return ;
27- }
28- console . log ( `Found image at "${ self . _path } "` ) ;
26+ return new Promise ( ( resolve ) => {
27+ window . theme_utils ?. dirlist ( dir , false , ( dirFiles : string [ ] | undefined ) => {
28+ self . _exists = dirFiles !== undefined && dirFiles . includes ( self . _path ) ;
29+ resolve ( self . _exists ) ;
30+ } ) ;
2931 } ) ;
3032 }
3133
3234 public get path ( ) : string {
3335 return this . _path ;
3436 }
35-
36- public get exists ( ) : boolean {
37- return this . _exists ;
38- }
3937}
4038
4139
Original file line number Diff line number Diff line change @@ -33,9 +33,10 @@ export class UI {
3333 this . applyHiDpiScaling ( ) ;
3434
3535 // Set up logo
36- if ( data . logo . exists ) {
37- this . _logo . src = data . logo . path ;
38- }
36+ this . _logo . src = data . logo . path ;
37+ this . _logo . addEventListener ( 'error' , ( ) => {
38+ console . warn ( `Logo image not found at ${ data . logo . path } ` ) ;
39+ } ) ;
3940
4041 // Check for active sessions
4142 const activeSession = lightdm . users . find ( ( user : LightDMUser ) => user . logged_in ) ;
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ export class LockScreenUI extends UIScreen {
5151 this . _getAndSetLockedTimestamp ( ) ;
5252 }
5353
54- protected _initForm ( ) : void {
54+ protected async _initForm ( ) : Promise < void > {
5555 const form = this . _form as UILockScreenElements ;
5656
5757 // Populate lock screen data
@@ -71,7 +71,7 @@ export class LockScreenUI extends UIScreen {
7171 console . warn ( `Failed to load avatar for user ${ this . _activeSession . username } ` ) ;
7272 form . avatar . src = "assets/default-user.png" ; // Load fallback image
7373 } ) ;
74- if ( window . data . userImage . exists ) {
74+ if ( await window . data . userImage . exists ) {
7575 // Show the user's avatar from the /tmp folder
7676 form . avatar . src = window . data . userImage . path ;
7777 }
@@ -80,7 +80,7 @@ export class LockScreenUI extends UIScreen {
8080 // The greeter does not have access to the user's home folder...
8181 form . avatar . src = this . _activeSession . image ;
8282 }
83- else if ( window . data . userDefaultImage . exists ) {
83+ else if ( await window . data . userDefaultImage . exists ) {
8484 form . avatar . src = window . data . userDefaultImage . path ;
8585 }
8686 form . displayName . innerText = this . _activeSession . display_name ?? this . _activeSession . username ;
Original file line number Diff line number Diff line change @@ -13,16 +13,16 @@ export class WallpaperUI {
1313 this . displayWallpaper ( ) ;
1414 }
1515
16- public displayWallpaper ( ) : boolean {
16+ public async displayWallpaper ( ) : Promise < boolean > {
1717 let wallpaper : GreeterImage = window . data . loginScreenWallpaper ;
1818 if ( this . _isLockScreen ) {
1919 this . _blurFilter . style . display = 'block' ;
20- if ( window . data . userLockScreenWallpaper . exists ) {
20+ if ( await window . data . userLockScreenWallpaper . exists ) {
2121 wallpaper = window . data . userLockScreenWallpaper ;
2222 }
2323 }
2424
25- if ( wallpaper . exists ) {
25+ if ( await wallpaper . exists ) {
2626 // Set wallpaper (yes for some reason the file path just works without file://)
2727 // Actually, file:// will even cause the image to not load.
2828 this . _element . style . backgroundImage = 'url("' + wallpaper . path + '")' ;
You can’t perform that action at this time.
0 commit comments