added db query optimizations to playlists view, added caching
This commit is contained in:
@@ -91,6 +91,38 @@ export namespace playlist {
|
||||
this.Duration = source["Duration"];
|
||||
}
|
||||
}
|
||||
export class WithTracks {
|
||||
Summary: Summary;
|
||||
Tracks: Track[];
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new WithTracks(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.Summary = this.convertValues(source["Summary"], Summary);
|
||||
this.Tracks = this.convertValues(source["Tracks"], Track);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -11,6 +11,8 @@ export function CreatePlaylistWithTracks(arg1:string,arg2:Array<string>):Promise
|
||||
|
||||
export function GetAllPlaylists():Promise<Array<playlist.Summary>>;
|
||||
|
||||
export function GetAllPlaylistsWithTracks():Promise<Array<playlist.WithTracks>>;
|
||||
|
||||
export function GetPlaylistTracks(arg1:number):Promise<Array<playlist.Track>>;
|
||||
|
||||
export function SetContext(arg1:context.Context):Promise<void>;
|
||||
|
||||
@@ -18,6 +18,10 @@ export function GetAllPlaylists() {
|
||||
return window['go']['playlist']['Service']['GetAllPlaylists']();
|
||||
}
|
||||
|
||||
export function GetAllPlaylistsWithTracks() {
|
||||
return window['go']['playlist']['Service']['GetAllPlaylistsWithTracks']();
|
||||
}
|
||||
|
||||
export function GetPlaylistTracks(arg1) {
|
||||
return window['go']['playlist']['Service']['GetPlaylistTracks'](arg1);
|
||||
}
|
||||
|
||||
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user