Hi Freshworks Developer Community,
I’m facing an issue with the Freshworks FDK while working with a React-based app.
I have an app that can be opened in the Ticket Sidebar, and from there I open a modal. I’m using c.instance.context() to retrieve the modal context and c.data.get('ticket') to retrieve the ticket data.
The issue occurs when I navigate from one ticket to the next ticket while the app/modal is involved.
Expected behavior:
When I navigate to the next ticket, the app should retrieve the Client Location corresponding to the current ticket, which is also displayed in the Ticket Sidebar.
Actual behavior:
After navigating to the next ticket, the Client Location is incorrectly returned as “Model” instead of the actual location displayed in the Ticket Sidebar.
Here is the relevant part of my code:
React.useEffect(() => {
async function detectLocation(c) {
if (window.location.pathname.includes('modal.html')) {
try {
const ctx = await c.instance.context();
setModalData(ctx?.data || null);
} catch {}
setLocation('modal');
return;
}
sessionStorage.removeItem('fw_is_modal');
try {
await c.data.get('ticket');
setLocation('ticket_sidebar');
} catch {
setLocation('full_page_app');
}
}
function appDeactiveHandler() {
sessionStorage.removeItem('fw_modal_open');
sessionStorage.removeItem('fw_is_modal');
}
app.initialized().then(async (c) => {
c.events.on('app.activated', () => detectLocation(c));
c.events.on('app.deactivated', appDeactiveHandler);
await detectLocation(c);
setClient(c);
});
}, []);
My concern is that when moving to the next ticket, the existing app/modal instance or context may not be getting refreshed with the new ticket information.
Questions:
- Is there a specific Freshworks event that should be handled when navigating between tickets to get the updated ticket context?
- Should
c.data.get('ticket')be called again when the ticket changes? - Is there a recommended way to get the current Ticket Sidebar context after navigating to the next ticket?
- Could
c.instance.context()retain the previous modal context when navigating between tickets?
Any guidance on the correct FDK event or recommended approach for handling ticket navigation and updated context/data would be greatly appreciated.
Thanks in advance!