@ngenux/ngage-whiteboarding 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -37071,6 +37071,14 @@ const Undo2 = createLucideIcon("Undo2", [
37071
37071
  const TopToolbar = ({ queueAction, handleExportImage, handleClear, handleLockToggle, isAdmin = false, hasToolAccess = false, isGloballyUnlocked = false, shouldBeOpenByDefault = true, hasVideoBackground = false }) => {
37072
37072
  const { state, dispatch } = useWhiteboard();
37073
37073
  const [isVisible, setIsVisible] = React.useState(shouldBeOpenByDefault);
37074
+ const [isInitialized, setIsInitialized] = React.useState(false);
37075
+ // Wait for context to be fully initialized before rendering
37076
+ // Check that state.userId is set to ensure context is fully ready
37077
+ React.useEffect(() => {
37078
+ if (state && state.userId) {
37079
+ setIsInitialized(true);
37080
+ }
37081
+ }, [state]);
37074
37082
  const handleToggleVisibility = () => {
37075
37083
  setIsVisible(!isVisible);
37076
37084
  };
@@ -37132,6 +37140,10 @@ const TopToolbar = ({ queueAction, handleExportImage, handleClear, handleLockTog
37132
37140
  }
37133
37141
  }
37134
37142
  };
37143
+ // Don't render until fully initialized to prevent race conditions
37144
+ if (!isInitialized) {
37145
+ return null;
37146
+ }
37135
37147
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "absolute top-5 left-1/2 transform -translate-x-1/2 flex flex-col items-center z-10", children: [!isVisible && (jsxRuntime.jsx("button", { className: "w-10 h-10 flex items-center justify-center bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300", onClick: handleToggleVisibility, title: "Show Tools", children: jsxRuntime.jsx(ChevronDown, { size: 16, className: "text-current" }) })), isVisible && (jsxRuntime.jsx("div", { className: "bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg", children: jsxRuntime.jsxs("div", { className: "flex items-center gap-1 p-1", children: [isAdmin && (jsxRuntime.jsx("button", { className: `w-10 h-10 flex items-center justify-center rounded transition-colors ${isGloballyUnlocked
37136
37148
  ? 'bg-green-100 dark:bg-green-900/50 text-green-600 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/70'
37137
37149
  : 'bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600'}`, onClick: handleLockToggle, title: isGloballyUnlocked ? 'Whiteboard unlocked for all users - Click to lock' : 'Whiteboard locked - Click to unlock for all users', children: isGloballyUnlocked ? jsxRuntime.jsx(LockOpen, { size: 16, className: "text-current" }) : jsxRuntime.jsx(Lock, { size: 16, className: "text-current" }) })), jsxRuntime.jsx("button", { className: `w-10 h-10 flex items-center justify-center rounded ${hasToolAccess ? 'hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300' : 'opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600'}`, onClick: handleUndo, disabled: !hasToolAccess, title: hasToolAccess ? 'Undo' : 'Access restricted', children: jsxRuntime.jsx(Undo2, { size: 16, className: "text-current" }) }), jsxRuntime.jsx("button", { className: `w-10 h-10 flex items-center justify-center rounded ${hasToolAccess ? 'hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300' : 'opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600'}`, onClick: handleRedo, disabled: !hasToolAccess, title: hasToolAccess ? 'Redo' : 'Access restricted', children: jsxRuntime.jsx(Redo2, { size: 16, className: "text-current" }) }), jsxRuntime.jsx("div", { className: "w-px h-6 bg-gray-300 dark:bg-gray-600 mx-1" }), tools.map((tool) => (jsxRuntime.jsx("button", { className: `w-10 h-10 flex items-center justify-center rounded transition-colors ${!hasToolAccess
@@ -37149,6 +37161,14 @@ const LeftSidebar = ({ queueAction, hasToolAccess = false, shouldBeOpenByDefault
37149
37161
  const [position, setPosition] = React.useState({ x: 20, y: 80 });
37150
37162
  const [hasEverHadAccess, setHasEverHadAccess] = React.useState(hasToolAccess);
37151
37163
  const [wasManuallyClosedAfterAccess, setWasManuallyClosedAfterAccess] = React.useState(false);
37164
+ const [isInitialized, setIsInitialized] = React.useState(false);
37165
+ // Wait for context to be fully initialized before rendering
37166
+ // Check that state.userId is set to ensure context is fully ready
37167
+ React.useEffect(() => {
37168
+ if (state && state.userId) {
37169
+ setIsInitialized(true);
37170
+ }
37171
+ }, [state]);
37152
37172
  // Set white as default stroke color when video background is active
37153
37173
  React.useEffect(() => {
37154
37174
  if (hasVideoBackground && state.color === '#000000') {
@@ -37269,6 +37289,10 @@ const LeftSidebar = ({ queueAction, hasToolAccess = false, shouldBeOpenByDefault
37269
37289
  // Only update local state - don't broadcast opacity changes to other users
37270
37290
  dispatch({ type: 'SET_OPACITY', payload: opacity });
37271
37291
  };
37292
+ // Don't render until fully initialized to prevent race conditions
37293
+ if (!isInitialized) {
37294
+ return null;
37295
+ }
37272
37296
  if (!isVisible) {
37273
37297
  // Only show the sidebar toggle button if user has tool access
37274
37298
  if (!hasToolAccess) {