diff --git a/source/ui/screens/List.ts b/source/ui/screens/List.ts index cfbe8c3d..64ae9278 100644 --- a/source/ui/screens/List.ts +++ b/source/ui/screens/List.ts @@ -38,6 +38,9 @@ interface Upload{ @property({type: Array, attribute: false}) selection = []; + @property({type: Function, attribute: false}) + sort: Parameters[0]; + get isUser(){ return (this.user && !this.user.isDefaultUser); } @@ -127,12 +130,14 @@ interface Upload{ if(!this.isUser){ return html``; } - let mode = (this.user?"write":"read") + let mode = (this.user?"write":"read"); if(!this.list){ return html`
`; } - let orderTypes = ["alphabet","ctime","mtime"] + let orderTypes = ["alphabet","ctime","mtime"]; + + let sortedList = this.list.sort(this.sort); return html`
@@ -169,11 +174,11 @@ interface Upload{
- ${(this.list.length == 0 && Object.keys(this.uploads).length == 0)? + ${(sortedList.length == 0 && Object.keys(this.uploads).length == 0)? html`

No scenes available

`: repeat([ ...Object.keys(this.uploads).map(name=>({name})), - ...this.list, + ...sortedList, ],({name})=>name , (scene)=>this.renderScene(mode, scene)) } ${this.dragover ?html`
Drop item here
`:""} @@ -229,9 +234,9 @@ interface Upload{ onSelectOrder = (ev)=>{ let value = ev.target.value; - if(value == "alphabet") this.list.sort((a, b) => a.name.localeCompare(b.name)); - if(value == "ctime") this.list.sort((a, b) => new Date(b.ctime).valueOf() - new Date(a.ctime).valueOf()); - if(value == "mtime") this.list.sort((a, b) => new Date(b.mtime).valueOf() - new Date(a.mtime).valueOf()); + if(value == "alphabet") this.sort = (a, b) => a.name.localeCompare(b.name); + if(value == "ctime") this.sort = (a, b) => new Date(b.ctime).valueOf() - new Date(a.ctime).valueOf(); + if(value == "mtime") this.sort = (a, b) => new Date(b.mtime).valueOf() - new Date(a.mtime).valueOf(); this.requestUpdate(); }