up
This commit is contained in:
@@ -30,16 +30,14 @@ export class Controller {
|
||||
state: State = { revision: 0, command: null, status: 'idle', error: '', samples: [] }
|
||||
private seen = new Set<string>()
|
||||
private startedAt = 0
|
||||
private origin: 'computer' | 'phone' = 'computer'
|
||||
constructor(private publish: (state: State) => void) {}
|
||||
command(input: unknown, origin: 'computer' | 'phone' = 'computer') {
|
||||
command(input: unknown) {
|
||||
const command = parseCommand(input)
|
||||
if (this.seen.has(command.id)) return
|
||||
this.seen.add(command.id)
|
||||
// shortcut: помним 4096 команд стенда; долговременная дедупликация — SCREEN-004.
|
||||
if (this.seen.size > 4096) this.seen.delete(this.seen.values().next().value!)
|
||||
this.startedAt = performance.now()
|
||||
this.origin = origin
|
||||
this.state = {
|
||||
...this.state,
|
||||
revision: this.state.revision + 1,
|
||||
@@ -70,7 +68,6 @@ export class Controller {
|
||||
...this.state.samples.slice(-399),
|
||||
{
|
||||
media: this.state.command.media,
|
||||
origin: this.origin,
|
||||
milliseconds: performance.now() - this.startedAt,
|
||||
},
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user