feat: add download button

This commit is contained in:
Simon Ding
2024-07-16 15:12:25 +08:00
parent 9dd8cb2d21
commit cb0a95c537
2 changed files with 17 additions and 2 deletions

View File

@@ -61,11 +61,16 @@ func (s *Server) moveCompletedTask(id int) (err error) {
defer func () {
if err != nil {
s.db.SetHistoryStatus(r.ID, history.StatusFail)
s.db.SetEpisodeStatus(r.EpisodeID, episode.StatusMissing)
if r.EpisodeID != 0 {
s.db.SetEpisodeStatus(r.EpisodeID, episode.StatusMissing)
}
} else {
delete(s.tasks, r.ID)
s.db.SetHistoryStatus(r.ID, history.StatusSuccess)
s.db.SetEpisodeStatus(r.EpisodeID, episode.StatusDownloaded)
if r.EpisodeID != 0 {
s.db.SetEpisodeStatus(r.EpisodeID, episode.StatusDownloaded)
}
torrent.Remove()
}

View File

@@ -178,6 +178,7 @@ class _MovieDetailsPageState extends ConsumerState<MovieDetailsPage> {
DataColumn(label: Text("大小")),
DataColumn(label: Text("seeders")),
DataColumn(label: Text("peers")),
DataColumn(label: Text("操作"))
],
rows: List.generate(v.length, (i) {
final torrent = v[i];
@@ -186,6 +187,15 @@ class _MovieDetailsPageState extends ConsumerState<MovieDetailsPage> {
DataCell(Text("${torrent.size?.readableFileSize()}")),
DataCell(Text("${torrent.seeders}")),
DataCell(Text("${torrent.peers}")),
DataCell(IconButton.filledTonal(
icon: const Icon(Icons.download),
onPressed: () async {
await ref
.read(movieTorrentsDataProvider(this.id)
.notifier)
.download(torrent.link!);
},
))
]);
}),
);