mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-07 18:49:45 +00:00
fixed continue watching
This commit is contained in:
parent
375ea61b37
commit
facffe0f19
3 changed files with 48 additions and 23 deletions
BIN
assets/Dog Running.lottie
Normal file
BIN
assets/Dog Running.lottie
Normal file
Binary file not shown.
|
|
@ -475,14 +475,8 @@ const ContinueWatchingSection = React.forwardRef<ContinueWatchingRef>((props, re
|
||||||
// Trigger haptic feedback for confirmation
|
// Trigger haptic feedback for confirmation
|
||||||
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
|
|
||||||
// Remove the watch progress
|
// Remove all watch progress for this content (all episodes if series)
|
||||||
await storageService.removeWatchProgress(
|
await storageService.removeAllWatchProgressForContent(item.id, item.type, { addBaseTombstone: true });
|
||||||
item.id,
|
|
||||||
item.type,
|
|
||||||
item.type === 'series' && item.season && item.episode
|
|
||||||
? `${item.season}:${item.episode}`
|
|
||||||
: undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
// Also remove from Trakt playback queue if authenticated
|
// Also remove from Trakt playback queue if authenticated
|
||||||
const traktService = TraktService.getInstance();
|
const traktService = TraktService.getInstance();
|
||||||
|
|
@ -491,18 +485,13 @@ const ContinueWatchingSection = React.forwardRef<ContinueWatchingRef>((props, re
|
||||||
await traktService.deletePlaybackForContent(
|
await traktService.deletePlaybackForContent(
|
||||||
item.id,
|
item.id,
|
||||||
item.type as 'movie' | 'series',
|
item.type as 'movie' | 'series',
|
||||||
item.season,
|
undefined,
|
||||||
item.episode
|
undefined
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the list by filtering out the deleted item
|
// Update the list by filtering out the deleted item
|
||||||
setContinueWatchingItems(prev =>
|
setContinueWatchingItems(prev => prev.filter(i => i.id !== item.id));
|
||||||
prev.filter(i => i.id !== item.id ||
|
|
||||||
(i.type === 'series' && item.type === 'series' &&
|
|
||||||
(i.season !== item.season || i.episode !== item.episode))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Failed to remove watch progress:', error);
|
logger.error('Failed to remove watch progress:', error);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -172,9 +172,12 @@ class StorageService {
|
||||||
// Do not resurrect if tombstone exists and is newer than this progress
|
// Do not resurrect if tombstone exists and is newer than this progress
|
||||||
try {
|
try {
|
||||||
const tombstones = await this.getWatchProgressTombstones();
|
const tombstones = await this.getWatchProgressTombstones();
|
||||||
const tombKey = this.buildWpKeyString(id, type, episodeId);
|
const exactKey = this.buildWpKeyString(id, type, episodeId);
|
||||||
const tombAt = tombstones[tombKey];
|
const baseKey = this.buildWpKeyString(id, type, undefined);
|
||||||
if (tombAt && (progress.lastUpdated == null || progress.lastUpdated <= tombAt)) {
|
const exactTombAt = tombstones[exactKey];
|
||||||
|
const baseTombAt = tombstones[baseKey];
|
||||||
|
const newestTombAt = Math.max(exactTombAt || 0, baseTombAt || 0);
|
||||||
|
if (newestTombAt && (progress.lastUpdated == null || progress.lastUpdated <= newestTombAt)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
@ -355,6 +358,7 @@ class StorageService {
|
||||||
}>> {
|
}>> {
|
||||||
try {
|
try {
|
||||||
const allProgress = await this.getAllWatchProgress();
|
const allProgress = await this.getAllWatchProgress();
|
||||||
|
const tombstones = await this.getWatchProgressTombstones();
|
||||||
const unsynced: Array<{
|
const unsynced: Array<{
|
||||||
key: string;
|
key: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -364,10 +368,13 @@ class StorageService {
|
||||||
}> = [];
|
}> = [];
|
||||||
|
|
||||||
for (const [key, progress] of Object.entries(allProgress)) {
|
for (const [key, progress] of Object.entries(allProgress)) {
|
||||||
// Skip if tombstoned and tombstone is newer
|
// Skip if tombstoned (either exact entry or base content) and tombstone is newer
|
||||||
const tombstones = await this.getWatchProgressTombstones();
|
const parts = key.split(':');
|
||||||
const tombAt = tombstones[key];
|
const baseKey = `${parts[0]}:${parts[1]}`;
|
||||||
if (tombAt && (progress.lastUpdated == null || progress.lastUpdated <= tombAt)) {
|
const exactTombAt = tombstones[key];
|
||||||
|
const baseTombAt = tombstones[baseKey];
|
||||||
|
const newestTombAt = Math.max(exactTombAt || 0, baseTombAt || 0);
|
||||||
|
if (newestTombAt && (progress.lastUpdated == null || progress.lastUpdated <= newestTombAt)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Check if needs sync (either never synced or local progress is newer)
|
// Check if needs sync (either never synced or local progress is newer)
|
||||||
|
|
@ -398,6 +405,35 @@ class StorageService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all watch progress entries for a given content id and type.
|
||||||
|
* Optionally add a base tombstone to prevent reappearance.
|
||||||
|
*/
|
||||||
|
public async removeAllWatchProgressForContent(
|
||||||
|
id: string,
|
||||||
|
type: string,
|
||||||
|
options?: { addBaseTombstone?: boolean }
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const all = await this.getAllWatchProgress();
|
||||||
|
const prefix = `${type}:${id}`;
|
||||||
|
const removals: Array<Promise<void>> = [];
|
||||||
|
for (const key of Object.keys(all)) {
|
||||||
|
if (key === prefix || key.startsWith(`${prefix}:`)) {
|
||||||
|
// Compute episodeId if present
|
||||||
|
const episodeId = key.length > prefix.length + 1 ? key.slice(prefix.length + 1) : undefined;
|
||||||
|
removals.push(this.removeWatchProgress(id, type, episodeId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Promise.allSettled(removals);
|
||||||
|
if (options?.addBaseTombstone) {
|
||||||
|
await this.addWatchProgressTombstone(id, type);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Error removing all watch progress for content:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge Trakt progress with local progress using exact time when available
|
* Merge Trakt progress with local progress using exact time when available
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue