diff --git a/src/components/SideDrawerView/index.tsx b/src/components/SideDrawerView/index.tsx index ff2ad66d..d0a2b550 100644 --- a/src/components/SideDrawerView/index.tsx +++ b/src/components/SideDrawerView/index.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { RcDrawer, styled } from '@ringcentral/juno'; import { SmartNoteApp } from './SmartNoteApp'; @@ -21,7 +21,17 @@ export function SideDrawerView({ onSmartNoteSave, }) { const [session, setSession] = useState(null); + const sessionRef = useRef(session); useEffect(() => { + if ( + sessionRef.current && + smartNoteSession && + sessionRef.current.id === smartNoteSession.id + ) { + // avoid re-render when session is the same + return; + } + sessionRef.current = smartNoteSession; setSession(null); const timeout = setTimeout(() => { setSession(smartNoteSession); diff --git a/src/modules/SmartNotes/index.ts b/src/modules/SmartNotes/index.ts index 7130847a..6e76e2b8 100644 --- a/src/modules/SmartNotes/index.ts +++ b/src/modules/SmartNotes/index.ts @@ -280,6 +280,14 @@ export class SmartNotes extends RcModuleV2 { if (!smartNoteClient) { return; } + if ( + this.session && + this.session.id === session.id && + this.session.status === 'Disconnected' + ) { + // avoid duplicated call + return; + } if (smartNoteClient.transcriptions.length > 1) { this.addRecentNotedCall(session.id); }