mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
fix watchers and intervals.
This commit is contained in:
parent
c8c7df7c3c
commit
4b1fbbf836
@ -561,7 +561,7 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||||||
let packetsLost: number
|
let packetsLost: number
|
||||||
let packetsReceived: number
|
let packetsReceived: number
|
||||||
|
|
||||||
const timer = setInterval(async () => {
|
const timer = window.setInterval(async () => {
|
||||||
if (!this._peer) return
|
if (!this._peer) return
|
||||||
|
|
||||||
let stats: RTCStatsReport | undefined = undefined
|
let stats: RTCStatsReport | undefined = undefined
|
||||||
@ -620,7 +620,7 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||||||
}, ms)
|
}, ms)
|
||||||
|
|
||||||
return function () {
|
return function () {
|
||||||
clearInterval(timer)
|
window.clearInterval(timer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,12 +243,9 @@ const is_touch_device = computed(() => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(private_mode_enabled, (enabled) => {
|
||||||
() => private_mode_enabled.value,
|
|
||||||
(enabled) => {
|
|
||||||
connection.webrtc.paused = enabled
|
connection.webrtc.paused = enabled
|
||||||
},
|
})
|
||||||
)
|
|
||||||
|
|
||||||
const screencastReady = ref(false)
|
const screencastReady = ref(false)
|
||||||
const screencast = computed(() => {
|
const screencast = computed(() => {
|
||||||
@ -304,13 +301,9 @@ function setUrl(url: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(() => props.server, (url) => {
|
||||||
() => props.server,
|
|
||||||
(url) => {
|
|
||||||
url && setUrl(url)
|
url && setUrl(url)
|
||||||
},
|
}, { immediate: true })
|
||||||
{ immediate: true },
|
|
||||||
)
|
|
||||||
|
|
||||||
async function authenticate(token?: string) {
|
async function authenticate(token?: string) {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
@ -722,7 +722,9 @@ function restartInactiveCursorInterval() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([focused, props.isControling, props.inactiveCursors], restartInactiveCursorInterval)
|
watch(focused, restartInactiveCursorInterval)
|
||||||
|
watch(() => props.inactiveCursors, restartInactiveCursorInterval)
|
||||||
|
watch(() => props.isControling, restartInactiveCursorInterval)
|
||||||
|
|
||||||
function saveInactiveMousePos(e: MouseEvent) {
|
function saveInactiveMousePos(e: MouseEvent) {
|
||||||
const pos = getMousePos(e.clientX, e.clientY)
|
const pos = getMousePos(e.clientX, e.clientY)
|
||||||
|
@ -629,13 +629,13 @@ function screenChangingToggle() {
|
|||||||
let sizes = props.neko.state.screen.configurations
|
let sizes = props.neko.state.screen.configurations
|
||||||
let len = sizes.length
|
let len = sizes.length
|
||||||
|
|
||||||
screen_interval = setInterval(() => {
|
screen_interval = window.setInterval(() => {
|
||||||
let { width, height, rate } = sizes[Math.floor(Math.random() * len)]
|
let { width, height, rate } = sizes[Math.floor(Math.random() * len)]
|
||||||
|
|
||||||
props.neko.setScreenSize(width, height, rate)
|
props.neko.setScreenSize(width, height, rate)
|
||||||
}, 10)
|
}, 10)
|
||||||
} else {
|
} else {
|
||||||
clearInterval(screen_interval)
|
window.clearInterval(screen_interval)
|
||||||
screen_interval = null
|
screen_interval = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -646,7 +646,7 @@ function setScreenConfiguration() {
|
|||||||
props.neko.setScreenSize(parseInt(width), parseInt(height), parseInt(rate))
|
props.neko.setScreenSize(parseInt(width), parseInt(height), parseInt(rate))
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(props.neko.state.screen.size, (val) => {
|
watch(() => props.neko.state.screen.size, (val) => {
|
||||||
screenConfiguration.value = `${val.width}x${val.height}@${val.rate}`
|
screenConfiguration.value = `${val.width}x${val.height}@${val.rate}`
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -656,14 +656,14 @@ function cursorMovingToggle() {
|
|||||||
if (cursor_interval === null) {
|
if (cursor_interval === null) {
|
||||||
let len = props.neko.state.screen.size.width
|
let len = props.neko.state.screen.size.width
|
||||||
|
|
||||||
cursor_interval = setInterval(() => {
|
cursor_interval = window.setInterval(() => {
|
||||||
let x = Math.floor(Math.random() * len)
|
let x = Math.floor(Math.random() * len)
|
||||||
let y = Math.floor(Math.random() * len)
|
let y = Math.floor(Math.random() * len)
|
||||||
|
|
||||||
props.neko.control.move({ x, y })
|
props.neko.control.move({ x, y })
|
||||||
}, 10)
|
}, 10)
|
||||||
} else {
|
} else {
|
||||||
clearInterval(cursor_interval)
|
window.clearInterval(cursor_interval)
|
||||||
cursor_interval = null
|
cursor_interval = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user