fix(ui): fix assist backwards compat for messages
This commit is contained in:
parent
ca80f4071f
commit
923fee77fe
5 changed files with 14 additions and 18 deletions
|
|
@ -171,14 +171,18 @@ export default class AssistManager {
|
|||
})
|
||||
|
||||
socket.on('messages', messages => {
|
||||
if (messages.data !== undefined) this.assistVersion = 2
|
||||
|
||||
const isOldVersion = messages.meta.version === 1
|
||||
this.assistVersion = messages.meta.version
|
||||
const data = messages.data || messages
|
||||
jmr.append(data) // as RawMessage[]
|
||||
if (waitingForMessages) {
|
||||
waitingForMessages = false // TODO: more explicit
|
||||
this.setStatus(ConnectionStatus.Connected)
|
||||
}
|
||||
if (messages.meta.tabId !== this.store.get().currentTab && isOldVersion) {
|
||||
reader.currentTab = messages.meta.tabId
|
||||
this.store.update({ currentTab: messages.meta.tabId })
|
||||
}
|
||||
|
||||
for (let msg = reader.readNext();msg !== null;msg = reader.readNext()) {
|
||||
this.handleMessage(msg, msg._index)
|
||||
|
|
@ -194,8 +198,7 @@ export default class AssistManager {
|
|||
socket.on('UPDATE_SESSION', (evData) => {
|
||||
const { meta = {}, data = {} } = evData
|
||||
const { tabId } = meta
|
||||
const usedData = this.assistVersion === 1 ? evData : data
|
||||
const { active } = usedData
|
||||
const { active } = data
|
||||
const currentTab = this.store.get().currentTab
|
||||
this.clearDisconnectTimeout()
|
||||
!this.inactiveTimeout && this.setStatus(ConnectionStatus.Connected)
|
||||
|
|
@ -204,9 +207,6 @@ export default class AssistManager {
|
|||
if (active) {
|
||||
this.setStatus(ConnectionStatus.Connected)
|
||||
} else {
|
||||
if (tabId === undefined) {
|
||||
this.inactiveTimeout = setTimeout(() => this.setStatus(ConnectionStatus.Inactive), 5000)
|
||||
}
|
||||
if (tabId === currentTab) {
|
||||
this.inactiveTimeout = setTimeout(() => this.setStatus(ConnectionStatus.Inactive), 5000)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ export interface State {
|
|||
}
|
||||
|
||||
export default class Call {
|
||||
private assistVersion = 1
|
||||
static readonly INITIAL_STATE: Readonly<State> = {
|
||||
calling: CallingState.NoCall
|
||||
}
|
||||
|
|
@ -66,7 +65,6 @@ export default class Call {
|
|||
socket.on("disconnect", () => {
|
||||
this.store.update({ calling: CallingState.NoCall })
|
||||
})
|
||||
this.assistVersion = this.getAssistVersion()
|
||||
}
|
||||
|
||||
private getPeer(): Promise<Peer> {
|
||||
|
|
@ -173,7 +171,7 @@ export default class Call {
|
|||
}
|
||||
|
||||
private emitData = (event: string, data?: any) => {
|
||||
if (this.assistVersion === 1) {
|
||||
if (this.getAssistVersion() === 1) {
|
||||
this.socket?.emit(event, data)
|
||||
} else {
|
||||
this.socket?.emit(event, { meta: { tabId: this.store.get().currentTab }, data })
|
||||
|
|
@ -238,7 +236,7 @@ export default class Call {
|
|||
if (!this.store.get().currentTab) {
|
||||
console.warn('No tab data to connect to peer')
|
||||
}
|
||||
const peerId = this.assistVersion === 1 ? this.peerID : `${this.peerID}-${tab || Object.keys(this.store.get().tabs)[0]}`
|
||||
const peerId = this.getAssistVersion() === 1 ? this.peerID : `${this.peerID}-${tab || Object.keys(this.store.get().tabs)[0]}`
|
||||
void this._peerConnection(peerId);
|
||||
this.emitData("_agent_name", appStore.getState().getIn([ 'user', 'account', 'name']))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export interface State {
|
|||
}
|
||||
|
||||
export default class RemoteControl {
|
||||
private assistVersion = 1
|
||||
static readonly INITIAL_STATE: Readonly<State> = {
|
||||
remoteControl: RemoteControlStatus.Disabled,
|
||||
annotating: false,
|
||||
|
|
@ -29,7 +28,7 @@ export default class RemoteControl {
|
|||
private screen: Screen,
|
||||
private agentInfo: Object,
|
||||
private onToggle: (active: boolean) => void,
|
||||
private getAssistVersion: () => number,
|
||||
private getAssistVersion: () => number
|
||||
){
|
||||
socket.on("control_granted", ({ meta, data }) => {
|
||||
this.toggleRemoteControl(data === socket.id)
|
||||
|
|
@ -49,7 +48,6 @@ export default class RemoteControl {
|
|||
socket.on("error", () => {
|
||||
this.toggleRemoteControl(false)
|
||||
})
|
||||
this.assistVersion = getAssistVersion()
|
||||
}
|
||||
|
||||
private onMouseMove = (e: MouseEvent): void => {
|
||||
|
|
@ -58,7 +56,7 @@ export default class RemoteControl {
|
|||
}
|
||||
|
||||
private emitData = (event: string, data?: any) => {
|
||||
if (this.assistVersion === 1) {
|
||||
if (this.getAssistVersion()) {
|
||||
this.socket.emit(event, data)
|
||||
} else {
|
||||
this.socket.emit(event, { meta: { tabId: this.store.get().currentTab }, data })
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker-assist",
|
||||
"description": "Tracker plugin for screen assistance through the WebRTC",
|
||||
"version": "6.0.0-beta.11",
|
||||
"version": "6.0.0",
|
||||
"keywords": [
|
||||
"WebRTC",
|
||||
"assistance",
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
"replace-paths": "replace-in-files cjs/* --string='@openreplay/tracker' --replacement='@openreplay/tracker/cjs' && replace-in-files cjs/* --string='/lib/' --replacement='/'",
|
||||
"replace-versions": "npm run replace-pkg-version && npm run replace-req-version",
|
||||
"replace-pkg-version": "replace-in-files lib/* cjs/* --string='PACKAGE_VERSION' --replacement=$npm_package_version",
|
||||
"replace-req-version": "replace-in-files lib/* cjs/* --string='REQUIRED_TRACKER_VERSION' --replacement='3.5.14'",
|
||||
"replace-req-version": "replace-in-files lib/* cjs/* --string='REQUIRED_TRACKER_VERSION' --replacement='8.0.0'",
|
||||
"prepublishOnly": "npm run build",
|
||||
"prepare": "cd ../../ && husky install tracker/.husky/",
|
||||
"lint-front": "lint-staged",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker",
|
||||
"description": "The OpenReplay tracker main package",
|
||||
"version": "8.0.0-beta.5",
|
||||
"version": "8.0.0",
|
||||
"keywords": [
|
||||
"logging",
|
||||
"replay"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue