feat: auto-set rewatch/watching status when starting playback of episode 1

This commit is contained in:
ThaUnknown 2025-09-03 00:42:22 +02:00
parent 9151d37754
commit 34cdb22ae8
No known key found for this signature in database
6 changed files with 25 additions and 12 deletions

View file

@ -1,6 +1,6 @@
{
"name": "ui",
"version": "6.4.117",
"version": "6.4.118",
"license": "BUSL-1.1",
"private": true,
"packageManager": "pnpm@9.15.5",

View file

@ -23,7 +23,7 @@
}
</script>
<Dialog.Root portal='html'>
<Dialog.Root portal='#root'>
<Dialog.Trigger asChild let:builder>
<Button size='icon-sm' variant='ghost' class='mr-1' disabled={isLocked || !$viewer?.viewer} builders={[builder]}>
<slot />

View file

@ -131,16 +131,13 @@
let lastDbl = 0
function customDoubleClick (e: MouseEvent) {
const now = Date.now()
if (now - lastDbl < (SUPPORTS.isAndroid ? 400 : 100)) {
if (now - lastDbl < (SUPPORTS.isAndroid ? 500 : 200)) {
dispatch('dblclick', e)
}
lastDbl = now
}
</script>
<!-- fix for android gestures not cancelling pointer when closing the app using gestures from the bottom which hovers the seekbar, insane. -->
<!-- <svelte:document on:visibilitychange={endHover} /> -->
<div class='w-full flex cursor-pointer relative group/seekbar touch-none !transform-none' class:!cursor-grab={seeking}
tabindex='0' role='slider' aria-valuenow='0'
id='player-seekbar'
@ -153,7 +150,8 @@
on:pointerup={endSeeking}
on:pointermove={calculatePositionProgress}
on:pointerleave={endHover}
on:pointercancel={endSeeking}>
on:pointercancel={endSeeking}
on:pointercancel={endHover}>
{#each segments as chapter, i (chapter)}
{@const { size, scale, offset } = chapter}
{@const active = seek && seek > offset && seek < offset + size}

View file

@ -117,7 +117,6 @@ export default new class AuthAggregator {
async watch (outdated: Media, progress: number) {
const media = (await client.single(outdated.id)).data?.Media ?? outdated
// TODO: auto re-watch status
const totalEps = episodes(media) ?? 1 // episodes or movie which is single episode
if (totalEps < progress) return // woah, bad data from resolver?!
@ -165,4 +164,18 @@ export default new class AuthAggregator {
sync.local && local.entry(variables)
])
}
async setInitialState (media: Media, episode: number) {
if (episode !== 1) return
const mediaList = this.mediaListEntry(media)
if (!mediaList) return await this.entry({ id: media.id, progress: 0, status: 'CURRENT' })
if (['COMPLETED', 'PLANNING', 'PAUSED'].includes(mediaList.status ?? '')) {
const status = mediaList.status === 'COMPLETED' ? 'REPEATING' : 'CURRENT'
const lists = (mediaList.customLists as Array<{enabled: boolean, name: string}> | undefined)?.filter(({ enabled }) => enabled).map(({ name }) => name) ?? []
return await this.entry({ id: media.id, progress: 0, status, lists })
}
}
}()

View file

@ -3,6 +3,7 @@ import { writable } from 'simple-store-svelte'
import { get } from 'svelte/store'
import { persisted } from 'svelte-persisted-store'
import client from '../auth/client'
import native from '../native'
import { SUPPORTS } from '../settings'
import { w2globby } from '../w2g/lobby'
@ -86,6 +87,7 @@ export const server = new class ServerClient {
if (!media || !id) return
debug('playing torrent', id, media.id, episode)
this.last.set({ id, media, episode })
client.setInitialState(media, episode)
this.active.value = this._play(id, media, episode)
w2globby.value?.mediaChange({ episode, mediaId: media.id, torrent: id })
return this.active.value

View file

@ -92,7 +92,7 @@ function save (namespaces) {
}
} catch (error) {
// Swallow
// XXX (@Qix-) should we be logging these?
// (@Qix-) should we be logging these?
}
}
@ -108,7 +108,7 @@ function load () {
r = exports.storage.getItem('debug')
} catch (error) {
// Swallow
// XXX (@Qix-) should we be logging these?
// (@Qix-) should we be logging these?
}
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
@ -137,7 +137,7 @@ function localstorage () {
return localStorage
} catch (error) {
// Swallow
// XXX (@Qix-) should we be logging these?
// (@Qix-) should we be logging these?
}
}
@ -289,7 +289,7 @@ function setup (env) {
debug.useColors = createDebug.useColors()
debug.color = createDebug.selectColor(namespace)
debug.extend = extend
debug.destroy = createDebug.destroy // XXX Temporary. Will be removed in the next major release.
debug.destroy = createDebug.destroy // Temporary. Will be removed in the next major release.
Object.defineProperty(debug, 'enabled', {
enumerable: true,