Skip to content

Commit

Permalink
fix: smart note re-render (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
embbnux authored Jan 6, 2025
1 parent 0a131e9 commit 1fdeafa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/SideDrawerView/index.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/modules/SmartNotes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1fdeafa

Please sign in to comment.