Skip to content

Commit 4e412e0

Browse files
committed
use asynchronous dirlist for image finding
1 parent 4fea6eb commit 4e412e0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

client/data.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ const PATH_USER_DEFAULT_IMAGE: string = '/usr/share/codam/web-greeter/user.png';
1212

1313
export class GreeterImage {
1414
private _path: string;
15-
private _exists: boolean;
15+
private _exists: boolean = false;
1616

1717
public constructor(path: string) {
1818
this._path = path;
1919

2020
// Check if file exists
2121
const dir = this._path.split('/').slice(0, -1).join('/');
22-
const dirFiles = window.theme_utils?.dirlist_sync(dir, false);
23-
this._exists = (dirFiles !== undefined && dirFiles.includes(this._path));
24-
if (!this._exists) {
25-
console.warn('Wallpaper file does not exist: ' + this._path);
26-
return;
27-
}
28-
29-
console.log(`Found image at "${this._path}"`);
22+
const self = this;
23+
window.theme_utils?.dirlist(dir, false, (dirFiles: string[] | undefined) => {
24+
self._exists = (dirFiles !== undefined && dirFiles.includes(self._path));
25+
if (!self._exists) {
26+
console.warn('Image file does not exist: ' + self._path);
27+
return;
28+
}
29+
console.log(`Found image at "${self._path}"`);
30+
});
3031
}
3132

3233
public get path(): string {

0 commit comments

Comments
 (0)