Soundboard: naming a clip used window.prompt, which Electron does not implement — it returned nothing, the flow aborted in silence, and adding a sound worked in the browser while doing nothing at all in the desktop app. Replaced with a two-step field inside the popover, identical in both. Spotify, three separate defects behind the two symptoms reported: Out of sync — a 20s poll stacked on the activity store's 5s debounce left everyone else on the previous track for up to 25s. The next poll is now scheduled just past the current track's end instead of on a fixed interval, and a track change bypasses the debounce (it happens once every few minutes; the debounce exists for chatty producers). Vanishing — a paused track, and the silent gap Spotify reports between two songs, both cleared the activity outright. Pausing is now carried as state rather than absence, and an empty answer is tolerated for 25s before the block comes down. Progress bar — timestamps are computed with the server's clock and were drawn against the viewer's, so any drift displaced the bar; and it kept advancing after a pause until the next poll. The ready payload now carries server time so each client can correct its own offset, and the bar freezes when paused. Tray, native notifications and system audio in screen share were all found already implemented and wired end to end; recorded in the roadmap rather than built again.
20 lines
691 B
TypeScript
20 lines
691 B
TypeScript
/**
|
|
* Offset between this machine's clock and the server's, in milliseconds.
|
|
*
|
|
* Activity timestamps (a Spotify track's start and end, for instance) are
|
|
* computed on the server and rendered here. A machine whose clock is a minute
|
|
* off would draw the progress bar a minute out of place — or past the end of
|
|
* the track — with nothing obviously wrong on screen.
|
|
*/
|
|
let offsetMs = 0;
|
|
|
|
/** Called on every `ready`: the round trip is short enough to ignore. */
|
|
export function setServerTime(serverTime: number): void {
|
|
offsetMs = Date.now() - serverTime;
|
|
}
|
|
|
|
/** `Date.now()` as the server would report it. */
|
|
export function serverNow(): number {
|
|
return Date.now() - offsetMs;
|
|
}
|