Skip to content

Commit 6acbbba

Browse files
committed
fix download also update watch state
1 parent 30765fe commit 6acbbba

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src-tauri/src/commands/request_plugin/get_episode_server.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22
use tracing::error;
33

4-
use chlaty_core::request_plugin::get_episode_server;
4+
use chlaty_core::request_plugin;
55
use chlaty_core::request_plugin::get_episode_server::DataResult;
66

77
use crate::commands::favorite::update_timestamp_favorite;
@@ -15,8 +15,9 @@ pub async fn get_episode_server(
1515
season_index: usize,
1616
episode_index: usize,
1717
episode_id: String,
18+
update_state: bool
1819
) -> Result<HashMap<String, Vec<DataResult>>, String> {
19-
let get_episode_server_result = get_episode_server::new(
20+
let get_episode_server_result = request_plugin::get_episode_server::new(
2021
&source,
2122
&plugin_id,
2223
season_index,
@@ -29,12 +30,13 @@ pub async fn get_episode_server(
2930
})?;
3031

3132
/* Update Current Watch */
32-
let mut local_manifest = get_local_manifest(source.clone(), id.clone()).await?;
33-
34-
local_manifest.current_watch_season_index = Some(season_index);
35-
local_manifest.current_watch_episode_index = Some(episode_index);
36-
save_local_manifest(source.clone(), id.clone(), local_manifest).await?;
37-
update_timestamp_favorite(source, id).await?;
33+
if update_state {
34+
let mut local_manifest = get_local_manifest(source.clone(), id.clone()).await?;
35+
local_manifest.current_watch_season_index = Some(season_index);
36+
local_manifest.current_watch_episode_index = Some(episode_index);
37+
save_local_manifest(source.clone(), id.clone(), local_manifest).await?;
38+
update_timestamp_favorite(source, id).await?;
39+
}
3840
/* --- */
3941

4042
return Ok(get_episode_server_result);

src/view/components/download.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function Download({
6767
const sample_episode_id = Object.keys(data)[0];
6868
const season_index = data[sample_episode_id].season_index;
6969
const episode_index = data[sample_episode_id].episode_index;
70-
get_episode_server(source, id, plugin_id, season_index, episode_index, sample_episode_id)
70+
get_episode_server(source, id, plugin_id, season_index, episode_index, sample_episode_id, false)
7171
.then((result)=>{
7272
console.log(result);
7373
SET_SERVER_DATA(result);

src/watch/components/watch.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ export default function Watch() {
165165
source, id, link_plugin_id,
166166
current_season_index(),
167167
current_episode_index(),
168-
current_episode_id()
168+
current_episode_id(),
169+
true
169170
);
170171
console.log("Episode Server: ", data);
171172
SET_EPISODE_SERVER_DATA(data);

src/watch/scripts/watch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export function get_episode_list(source: string, id: string, pluginId: string, l
1212
return invoke<EpisodeList[][][]>('get_episode_list', {source, id, pluginId, linkId});
1313
}
1414

15-
export function get_episode_server(source: string, id: string, pluginId: string, seasonIndex: number, episodeIndex: number, episodeId: string): Promise<EpisodeServerData> {
16-
return invoke<EpisodeServerData>('get_episode_server', {source, id, pluginId, seasonIndex, episodeIndex, episodeId});
15+
export function get_episode_server(source: string, id: string, pluginId: string, seasonIndex: number, episodeIndex: number, episodeId: string, updateState: boolean): Promise<EpisodeServerData> {
16+
return invoke<EpisodeServerData>('get_episode_server', {source, id, pluginId, seasonIndex, episodeIndex, episodeId, updateState});
1717
}
1818

1919
export function get_server(source: string, pluginId: string, id: string): Promise<ServerData> {

0 commit comments

Comments
 (0)