Merge pull request #925 from omgbeez/upstream/sorting
Update default torrent sorting to `added` in descending order
This commit is contained in:
commit
9e69020df8
1 changed files with 30 additions and 4 deletions
|
|
@ -21,8 +21,8 @@ export class TorrentTableComponent implements OnInit {
|
||||||
public torrents: Torrent[] = [];
|
public torrents: Torrent[] = [];
|
||||||
public selectedTorrents: string[] = [];
|
public selectedTorrents: string[] = [];
|
||||||
public error: string;
|
public error: string;
|
||||||
public sortProperty = 'rdName';
|
public sortProperty = 'added';
|
||||||
public sortDirection: 'asc' | 'desc' = 'asc';
|
public sortDirection: 'asc' | 'desc' = 'desc';
|
||||||
|
|
||||||
public isDeleteModalActive: boolean;
|
public isDeleteModalActive: boolean;
|
||||||
public deleteError: string;
|
public deleteError: string;
|
||||||
|
|
@ -57,6 +57,20 @@ export class TorrentTableComponent implements OnInit {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
// Load persisted sort settings (if any)
|
||||||
|
try {
|
||||||
|
const sp = localStorage.getItem('torrentTable.sortProperty');
|
||||||
|
const sd = localStorage.getItem('torrentTable.sortDirection');
|
||||||
|
if (sp) {
|
||||||
|
this.sortProperty = sp;
|
||||||
|
}
|
||||||
|
if (sd === 'asc' || sd === 'desc') {
|
||||||
|
this.sortDirection = sd as 'asc' | 'desc';
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
// Ignore storage errors (e.g., disabled storage)
|
||||||
|
}
|
||||||
|
|
||||||
this.torrentService.getDiskSpaceStatus().subscribe({
|
this.torrentService.getDiskSpaceStatus().subscribe({
|
||||||
next: (status) => {
|
next: (status) => {
|
||||||
this.diskSpaceStatus = status;
|
this.diskSpaceStatus = status;
|
||||||
|
|
@ -82,8 +96,20 @@ export class TorrentTableComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public sort(property: string): void {
|
public sort(property: string): void {
|
||||||
this.sortProperty = property;
|
if (this.sortProperty === property) {
|
||||||
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
||||||
|
} else {
|
||||||
|
this.sortProperty = property;
|
||||||
|
this.sortDirection = 'desc';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Persist sort settings
|
||||||
|
try {
|
||||||
|
localStorage.setItem('torrentTable.sortProperty', this.sortProperty);
|
||||||
|
localStorage.setItem('torrentTable.sortDirection', this.sortDirection);
|
||||||
|
} catch (_) {
|
||||||
|
// Ignore storage errors
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public openTorrent(torrentId: string): void {
|
public openTorrent(torrentId: string): void {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue