mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-05 00:59:49 +00:00
fix: potential w2g errors
This commit is contained in:
parent
d895cacd67
commit
41ce71e623
5 changed files with 35 additions and 11 deletions
|
|
@ -4,6 +4,8 @@
|
|||
import Message from './Message.svelte'
|
||||
import { SendHorizontal, DoorOpen, UserPlus } from 'lucide-svelte'
|
||||
export let invite
|
||||
|
||||
/** @type {import('simple-store-svelte').Writable<import('./w2g.js').W2GClient | null>} */
|
||||
export let state
|
||||
|
||||
function cleanup () {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@
|
|||
</script>
|
||||
|
||||
<div class='message d-flex flex-row mt-15' class:flex-row={incoming} class:flex-row-reverse={!incoming}>
|
||||
<img src={user.avatar?.medium || 'https://s4.anilist.co/file/anilistcdn/user/avatar/large/default.png'} alt='ProfilePicture' class='w-50 h-50 rounded-circle p-5 mt-auto' />
|
||||
<img src={user?.avatar?.medium || 'https://s4.anilist.co/file/anilistcdn/user/avatar/large/default.png'} alt='ProfilePicture' class='w-50 h-50 rounded-circle p-5 mt-auto' />
|
||||
<div class='d-flex flex-column px-10 align-items-start flex-auto' class:align-items-start={incoming} class:align-items-end={!incoming}>
|
||||
<div class='pb-5 d-flex flex-row align-items-center px-5'>
|
||||
<div class='font-weight-bold font-size-18 line-height-normal'>
|
||||
{user.name || 'Anonymous'}
|
||||
{user?.name || 'Anonymous'}
|
||||
</div>
|
||||
<div class='text-muted pl-10 font-size-12 line-height-normal'>
|
||||
{time.toLocaleTimeString()}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@
|
|||
</script>
|
||||
|
||||
<div class='d-flex align-items-center pb-10'>
|
||||
<img src={user.avatar?.medium || 'https://s4.anilist.co/file/anilistcdn/user/avatar/large/default.png'} alt='ProfilePicture' class='w-50 h-50 rounded-circle p-5 mt-auto' />
|
||||
<img src={user?.avatar?.medium || 'https://s4.anilist.co/file/anilistcdn/user/avatar/large/default.png'} alt='ProfilePicture' class='w-50 h-50 rounded-circle p-5 mt-auto' />
|
||||
<div class='font-size-18 line-height-normal pl-5'>
|
||||
{user.name || 'Anonymous'}
|
||||
{user?.name || 'Anonymous'}
|
||||
</div>
|
||||
{#if user.name}
|
||||
{#if user?.name}
|
||||
<span class='pointer text-primary d-flex align-items-center ml-auto' use:click={() => IPC.emit('open', 'https://anilist.co/user/' + user.name)}>
|
||||
<ExternalLink size='2rem' />
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ export class W2GClient extends EventEmitter {
|
|||
}
|
||||
|
||||
_playerStateChanged (state) {
|
||||
debug(`_playerStateChanged: ${this.player.paused} ${state.paused} ${this.player.time} ${state.time}`)
|
||||
debug(`_playerStateChanged: ${this.player?.paused} ${state?.paused} ${this.player?.time} ${state?.time}`)
|
||||
if (!state) return false
|
||||
if (this.player.paused !== state.paused || this.player.time !== state.time) {
|
||||
this.player = state
|
||||
return true
|
||||
|
|
@ -177,6 +178,7 @@ export class W2GClient extends EventEmitter {
|
|||
})
|
||||
break
|
||||
case EventTypes.MagnetLinkEvent: {
|
||||
if (data.payload?.magnet === undefined) break
|
||||
const { hash, magnet } = data.payload
|
||||
if (hash !== this.magnet?.hash) {
|
||||
this.isHost = false
|
||||
|
|
@ -187,6 +189,7 @@ export class W2GClient extends EventEmitter {
|
|||
break
|
||||
}
|
||||
case EventTypes.MediaIndexEvent: {
|
||||
if (data.payload?.index === undefined) break
|
||||
if (this.index !== data.payload.index) {
|
||||
this.index = data.payload.index
|
||||
this.emit('index', data.payload.index)
|
||||
|
|
@ -194,6 +197,7 @@ export class W2GClient extends EventEmitter {
|
|||
break
|
||||
}
|
||||
case EventTypes.PlayerStateEvent: {
|
||||
if (data.payload?.time === undefined) break
|
||||
if (this._playerStateChanged(data.payload)) this.emit('player', data.payload)
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ importers:
|
|||
version: 0.11.0(svelte@4.2.12)
|
||||
svelte-radix:
|
||||
specifier: ^1.1.0
|
||||
version: 1.1.0(svelte@4.2.12)
|
||||
version: 1.1.1(svelte@4.2.12)
|
||||
svelte-sonner:
|
||||
specifier: ^0.3.19
|
||||
version: 0.3.19(svelte@4.2.12)
|
||||
|
|
@ -3532,6 +3532,11 @@ packages:
|
|||
resolution: {integrity: sha512-GhiKG7CGTXzOQq56tIx40Ae26EbrgBq1owuuPqgCTaJDQYO1qW5G+YGaurOLx7s+Aaeta8MputrVFDr0kuiogg==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
|
||||
lucide-svelte@0.429.0:
|
||||
resolution: {integrity: sha512-3LwbxQn5i9/zQwMg0ZWT875djOEQoR3eM8ytOGqk0eRk4wkoqqgZX0Gr+aQjkd+RSDEVMXkIEoyW/1zLyXr/6g==}
|
||||
peerDependencies:
|
||||
svelte: ^3 || ^4 || ^5.0.0-next.42
|
||||
|
||||
magic-string@0.30.10:
|
||||
resolution: {integrity: sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==}
|
||||
|
||||
|
|
@ -4866,8 +4871,8 @@ packages:
|
|||
peerDependencies:
|
||||
svelte: ^3.19.0 || ^4.0.0
|
||||
|
||||
svelte-keybinds@1.0.8:
|
||||
resolution: {integrity: sha512-clP0/5XgMWXNlImQALBQYyrfN06fgWKWufoMumeGOABOsewScPsv1jRFZzks9f3Xh2e53XgZIx57Fb/a6d/ptw==}
|
||||
svelte-keybinds@1.0.9:
|
||||
resolution: {integrity: sha512-bQt9azkXX4SgMJpJzYWQB6D0hj45+Ro2+2Awr4YNtjmuRuKdio+Rxuhky5JJyBBfyRQ7YT63nSR3whH4FACv1A==}
|
||||
|
||||
svelte-loader@3.1.9:
|
||||
resolution: {integrity: sha512-RITPqze3TppOhaZF8SEFTDTwFHov17k3UkOjpxyL/No/YVrvckKmXWOEj7QEpsZZZSNQPb28tMZbHEI2xLhJMQ==}
|
||||
|
|
@ -4920,6 +4925,11 @@ packages:
|
|||
typescript:
|
||||
optional: true
|
||||
|
||||
svelte-radix@1.1.1:
|
||||
resolution: {integrity: sha512-TCbV7fzlJ2aEUB0nu2EodVA+r1eYj526IYpmGUTV32Z0bIrCUvx3K8xX3tcxR5dDFA5ZBU1Hxr4RYC4TDFEQ4A==}
|
||||
peerDependencies:
|
||||
svelte: ^3.54.0 || ^4.0.0 || ^5.0.0 || ^5.0.0-next.1
|
||||
|
||||
svelte-sonner@0.3.19:
|
||||
resolution: {integrity: sha512-jpPOgLtHwRaB6Vqo2dUQMv15/yUV/BQWTjKpEqQ11uqRSHKjAYUKZyGrHB2cQsGmyjR0JUzBD58btpgNqINQ/Q==}
|
||||
peerDependencies:
|
||||
|
|
@ -8853,7 +8863,7 @@ snapshots:
|
|||
array-union: 2.1.0
|
||||
dir-glob: 3.0.1
|
||||
fast-glob: 3.3.2
|
||||
ignore: 5.3.2
|
||||
ignore: 5.3.1
|
||||
merge2: 1.4.1
|
||||
slash: 3.0.0
|
||||
|
||||
|
|
@ -9500,6 +9510,10 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
lucide-svelte@0.429.0(svelte@4.2.12):
|
||||
dependencies:
|
||||
svelte: 4.2.12
|
||||
|
||||
magic-string@0.30.10:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.4.15
|
||||
|
|
@ -10976,7 +10990,7 @@ snapshots:
|
|||
dependencies:
|
||||
svelte: 4.2.12
|
||||
|
||||
svelte-keybinds@1.0.8: {}
|
||||
svelte-keybinds@1.0.9: {}
|
||||
|
||||
svelte-loader@3.1.9(svelte@4.2.12):
|
||||
dependencies:
|
||||
|
|
@ -11004,6 +11018,10 @@ snapshots:
|
|||
postcss-load-config: 3.1.4(postcss@8.4.38)(ts-node@10.9.2(typescript@5.4.5))
|
||||
typescript: 5.3.3
|
||||
|
||||
svelte-radix@1.1.1(svelte@4.2.12):
|
||||
dependencies:
|
||||
svelte: 4.2.12
|
||||
|
||||
svelte-sonner@0.3.19(svelte@4.2.12):
|
||||
dependencies:
|
||||
svelte: 4.2.12
|
||||
|
|
|
|||
Loading…
Reference in a new issue