Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed Jun 12, 2024
1 parent 108ec7f commit 8ae7a05
Show file tree
Hide file tree
Showing 27 changed files with 733 additions and 547 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,58 @@ export const OmnichannelRoomIconProvider: FC = ({ children }) => {
(): string[] => icons,
);

return (
<OmnichannelRoomIconContext.Provider
value={useMemo(() => {
const extractSnapshot = (app: string, iconName: string): AsyncState<string> => {
const icon = OmnichannelRoomIcon.get(app, iconName);

if (icon) {
return {
phase: AsyncStatePhase.RESOLVED,
value: icon,
error: undefined,
};
}
const contextValue = useMemo(() => {
const extractSnapshot = (app: string, iconName: string): AsyncState<string> => {
const icon = OmnichannelRoomIcon.get(app, iconName);

return {
phase: AsyncStatePhase.LOADING,
value: undefined,
error: undefined,
};
if (icon) {
return {
phase: AsyncStatePhase.RESOLVED,
value: icon,
error: undefined,
};
}

// We cache all the icons here, so that we can use them in the OmnichannelRoomIcon component
const snapshots = new Map<string, AsyncState<string>>();
return {
phase: AsyncStatePhase.LOADING,
value: undefined,
error: undefined,
};
};

return {
queryIcon: (
app: string,
iconName: string,
): [subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => AsyncState<string>] => [
(callback): (() => void) =>
OmnichannelRoomIcon.on(`${app}-${iconName}`, () => {
snapshots.set(`${app}-${iconName}`, extractSnapshot(app, iconName));
// We cache all the icons here, so that we can use them in the OmnichannelRoomIcon component
const snapshots = new Map<string, AsyncState<string>>();

// Then we call the callback (onStoreChange), signaling React to re-render
callback();
}),
return {
queryIcon: (
app: string,
iconName: string,
): [subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => AsyncState<string>] => [
(callback): (() => void) =>
OmnichannelRoomIcon.on(`${app}-${iconName}`, () => {
snapshots.set(`${app}-${iconName}`, extractSnapshot(app, iconName));

// No problem here, because it's return value is a cached in the snapshots map on subsequent calls
(): AsyncState<string> => {
let snapshot = snapshots.get(`${app}-${iconName}`);
// Then we call the callback (onStoreChange), signaling React to re-render
callback();
}),

if (!snapshot) {
snapshot = extractSnapshot(app, iconName);
snapshots.set(`${app}-${iconName}`, snapshot);
}
// No problem here, because it's return value is a cached in the snapshots map on subsequent calls
(): AsyncState<string> => {
let snapshot = snapshots.get(`${app}-${iconName}`);

return snapshot;
},
],
};
}, [])}
>
if (!snapshot) {
snapshot = extractSnapshot(app, iconName);
snapshots.set(`${app}-${iconName}`, snapshot);
}

return snapshot;
},
],
};
}, []);

return (
<OmnichannelRoomIconContext.Provider value={contextValue}>
{createPortal(
<svg
xmlns='http://www.w3.org/2000/svg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { lazy, useMemo } from 'react';

import type { RoomToolboxActionConfig } from '../../views/room/contexts/RoomToolboxContext';

const ContactHistory = lazy(() => import('../../views/omnichannel/contactHistory/ContactHistory'));
const ContactHistory = lazy(() => import('../../views/omnichannel/contactInfo/contactHistory/ContactHistory'));

Check failure on line 5 in apps/meteor/client/hooks/roomActions/useContactChatHistoryRoomAction.ts

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Unable to resolve path to module '../../views/omnichannel/contactInfo/contactHistory/ContactHistory'

// FIXME: this will be removed
export const useContactChatHistoryRoomAction = () => {
return useMemo(
(): RoomToolboxActionConfig => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { lazy, useMemo } from 'react';

import type { RoomToolboxActionConfig } from '../../views/room/contexts/RoomToolboxContext';

const ContactsContextualBar = lazy(() => import('../../views/omnichannel/directory/contacts/contextualBar/ContactsContextualBar'));
const ContactInfoRouter = lazy(() => import('../../views/omnichannel/contactInfo/ContactInfoRouter'));

export const useContactProfileRoomAction = () => {
return useMemo(
Expand All @@ -11,7 +11,7 @@ export const useContactProfileRoomAction = () => {
groups: ['live' /* , 'voip'*/],
title: 'Contact_Info',
icon: 'user',
tabComponent: ContactsContextualBar,
tabComponent: ContactInfoRouter,
order: 1,
}),
[],
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8ae7a05

Please sign in to comment.