Skip to content

Commit

Permalink
update UI to indicate media hasn't been released yet so no attempt ha…
Browse files Browse the repository at this point in the history
…s been made
  • Loading branch information
lardbit committed Nov 5, 2024
1 parent cfaa646 commit ff96611
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@
</td>
<td><span *ngIf="result.watchMedia.release_date">{{ result.watchMedia.release_date | date | date: 'shortDate' }}</span></td>
<td>{{ result.watchMedia.date_added | date | date: 'shortDate' }}</td>
<!-- show media status -->
<td>
<span *ngIf="result.watchMedia.last_attempt_date">{{ result.watchMedia.last_attempt_date | amTimeAgo }}</span>
<span *ngIf="!result.watchMedia.last_attempt_date" class="text-nowrap">working on it...</span>
<!-- media hasn't been released yet -->
<ng-container *ngIf="isReleaseInFuture(result.watchMedia)">
<span class="bg-warning">Media hasn't been released yet</span>
</ng-container>
<!-- last attempt date -->
<ng-container *ngIf="!isReleaseInFuture(result.watchMedia)">
<span *ngIf="result.watchMedia.last_attempt_date">{{ result.watchMedia.last_attempt_date | amTimeAgo }}</span>
<span *ngIf="!result.watchMedia.last_attempt_date" class="text-nowrap">working on it...</span>
</ng-container>
</td>
<td><span *ngIf="result.watchMedia.collected_date">{{ result.watchMedia.collected_date | date | date: 'shortDate' }}</span></td>
<td>
Expand Down
20 changes: 14 additions & 6 deletions src/frontend/src/app/torrent-details/torrent-details.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { ApiService } from '../api.service';
import { ToastrService } from 'ngx-toastr';
import { interval, Observable } from 'rxjs';
import { throttle } from 'rxjs/operators';
import {Component, OnInit, Input, OnDestroy} from '@angular/core';
import {ApiService} from '../api.service';
import {ToastrService} from 'ngx-toastr';
import {interval, Observable} from 'rxjs';
import {throttle} from 'rxjs/operators';
import * as moment from 'moment';

const POLL_TIME = 5000;

Expand All @@ -27,7 +28,8 @@ export class TorrentDetailsComponent implements OnInit, OnDestroy {
constructor(
private apiService: ApiService,
private toastr: ToastrService,
) {}
) {
}

ngOnDestroy() {
// stop polling for torrent details
Expand Down Expand Up @@ -101,6 +103,12 @@ export class TorrentDetailsComponent implements OnInit, OnDestroy {
return result.watchMedia.id;
}

public isReleaseInFuture(media: any): boolean {
const now = moment().format();
const releaseDate = moment(media.release_date || 'x');
return releaseDate.isValid() && releaseDate.isAfter(now, 'day');
}

protected _fetchTorrents(): Observable<any> {
this.isFetchingInitialTorrents = false;

Expand Down

0 comments on commit ff96611

Please sign in to comment.