@tuturuuu/ui 0.8.0 → 0.10.0
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/CHANGELOG.md +69 -0
- package/biome.json +1 -1
- package/package.json +74 -71
- package/src/components/ui/accordion.tsx +1 -1
- package/src/components/ui/breadcrumb.tsx +1 -1
- package/src/components/ui/calendar-app/calendar-page-shell.tsx +4 -0
- package/src/components/ui/calendar-app/components/calendar-connections-settings-content.tsx +239 -33
- package/src/components/ui/calendar-app/components/load-smart-scheduling-tasks.tsx +143 -0
- package/src/components/ui/calendar-app/components/priority-view.tsx +10 -3
- package/src/components/ui/calendar-app/components/tasks-sidebar.tsx +4 -116
- package/src/components/ui/calendar-app/components/use-calendar-connections-manager.ts +67 -2
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/carousel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-external-thread-panel.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-external-thread-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-operations-panel.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-operations-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-setup-panel.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-sidebar.test.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-sidebar.tsx +2 -2
- package/src/components/ui/chat/chat-agent-details-utils.test.ts +1 -1
- package/src/components/ui/chat/chat-agent-details-utils.tsx +1 -1
- package/src/components/ui/chat/chat-agent-details-zalo-personal-panel.tsx +2 -2
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/color-picker.tsx +1 -1
- package/src/components/ui/command.tsx +1 -1
- package/src/components/ui/context-menu.tsx +5 -1
- package/src/components/ui/custom/__tests__/settings-dialog-search.test.ts +78 -0
- package/src/components/ui/custom/__tests__/settings-dialog-shell-compile-graph.test.ts +76 -0
- package/src/components/ui/custom/__tests__/settings-dialog-shell.test.tsx +3 -0
- package/src/components/ui/custom/__tests__/workspace-select-helpers.test.ts +46 -1
- package/src/components/ui/custom/combobox.test.tsx +195 -0
- package/src/components/ui/custom/combobox.tsx +273 -156
- package/src/components/ui/custom/education/modules/youtube/delete-link-button.tsx +5 -13
- package/src/components/ui/custom/facebook-mockup/facebook-mockup.tsx +7 -1
- package/src/components/ui/custom/facebook-mockup/form.tsx +1 -1
- package/src/components/ui/custom/facebook-mockup/image-upload-field.tsx +1 -1
- package/src/components/ui/custom/facebook-mockup/preview.tsx +1 -1
- package/src/components/ui/custom/nav-link.test.tsx +165 -0
- package/src/components/ui/custom/nav-link.tsx +69 -11
- package/src/components/ui/custom/navigation.tsx +1 -0
- package/src/components/ui/custom/settings/task-settings.tsx +104 -0
- package/src/components/ui/custom/settings-dialog-search-loader.d.ts +5 -0
- package/src/components/ui/custom/settings-dialog-search-loader.js +3 -0
- package/src/components/ui/custom/settings-dialog-search.ts +75 -0
- package/src/components/ui/custom/settings-dialog-shell.tsx +65 -28
- package/src/components/ui/custom/theme-toggle.tsx +1 -1
- package/src/components/ui/custom/workspace-select-helpers.ts +23 -0
- package/src/components/ui/custom/workspace-select.tsx +25 -19
- package/src/components/ui/dialog.test.tsx +52 -0
- package/src/components/ui/dialog.tsx +6 -2
- package/src/components/ui/dropdown-menu.tsx +5 -1
- package/src/components/ui/finance/debts/debt-loan-form.tsx +12 -5
- package/src/components/ui/finance/debts/debt-loan-summary.tsx +3 -2
- package/src/components/ui/finance/debts/debts-page.test.tsx +54 -5
- package/src/components/ui/finance/debts/debts-page.tsx +15 -2
- package/src/components/ui/finance/invoices/components/subscription-group-selector.tsx +3 -5
- package/src/components/ui/finance/invoices/new-invoice-page.test.tsx +25 -5
- package/src/components/ui/finance/invoices/new-invoice-page.tsx +7 -2
- package/src/components/ui/finance/invoices/standard-invoice.tsx +4 -2
- package/src/components/ui/finance/invoices/subscription-invoice.tsx +4 -2
- package/src/components/ui/finance/invoices/utils.ts +3 -1
- package/src/components/ui/finance/transactions/form-content-dialog.tsx +3 -0
- package/src/components/ui/finance/transactions/form-types.ts +1 -0
- package/src/components/ui/finance/transactions/form.tsx +2 -0
- package/src/components/ui/finance/transactions/infinite-transactions-list.tsx +2 -0
- package/src/components/ui/finance/transactions/period-charts/category-breakdown-dialog.tsx +1 -1
- package/src/components/ui/finance/transactions/transaction-edit-dialog.tsx +1 -4
- package/src/components/ui/finance/transactions/transactions-create-summary.tsx +3 -0
- package/src/components/ui/finance/transactions/transactions-page.tsx +4 -1
- package/src/components/ui/finance/wallets/form.test.tsx +51 -3
- package/src/components/ui/finance/wallets/form.tsx +15 -4
- package/src/components/ui/finance/wallets/walletId/wallet-details-actions.tsx +4 -0
- package/src/components/ui/finance/wallets/walletId/wallet-details-page.tsx +4 -2
- package/src/components/ui/finance/wallets/wallets-data-table.tsx +1 -0
- package/src/components/ui/finance/wallets/wallets-page.tsx +5 -2
- package/src/components/ui/input-otp.tsx +1 -1
- package/src/components/ui/legacy/calendar/all-day-event-bar.tsx +28 -39
- package/src/components/ui/legacy/calendar/calendar-cell.tsx +2 -0
- package/src/components/ui/legacy/calendar/calendar-content.tsx +10 -6
- package/src/components/ui/legacy/calendar/calendar-header.tsx +23 -3
- package/src/components/ui/legacy/calendar/calendar-loading-skeleton.tsx +135 -0
- package/src/components/ui/legacy/calendar/calendar-matrix.tsx +175 -237
- package/src/components/ui/legacy/calendar/event-card.test.tsx +177 -0
- package/src/components/ui/legacy/calendar/event-card.tsx +220 -131
- package/src/components/ui/legacy/calendar/event-modal.tsx +17 -17
- package/src/components/ui/legacy/calendar/event-provider-display.tsx +69 -0
- package/src/components/ui/legacy/calendar/smart-calendar.test.tsx +86 -4
- package/src/components/ui/legacy/calendar/smart-calendar.tsx +32 -2
- package/src/components/ui/legacy/meet/create-plan-dialog.tsx +19 -10
- package/src/components/ui/navigation-menu.tsx +1 -1
- package/src/components/ui/pagination.tsx +1 -1
- package/src/components/ui/radio-group.tsx +1 -1
- package/src/components/ui/select.tsx +5 -1
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +1 -1
- package/src/components/ui/storefront/cart-popover.tsx +61 -0
- package/src/components/ui/storefront/cart-summary-parts.tsx +290 -0
- package/src/components/ui/storefront/cart-summary.tsx +93 -154
- package/src/components/ui/storefront/checkout-overlay.tsx +4 -5
- package/src/components/ui/storefront/listing-card.tsx +1 -1
- package/src/components/ui/storefront/merch-sections.tsx +70 -0
- package/src/components/ui/storefront/product-detail.tsx +1 -1
- package/src/components/ui/storefront/storefront-surface.test.tsx +106 -11
- package/src/components/ui/storefront/storefront-surface.tsx +101 -166
- package/src/components/ui/storefront/types.ts +4 -0
- package/src/components/ui/storefront/utils.ts +6 -0
- package/src/components/ui/text-editor/__tests__/extensions.test.ts +123 -0
- package/src/components/ui/text-editor/background-color-extension.ts +62 -0
- package/src/components/ui/text-editor/color-controls.tsx +284 -0
- package/src/components/ui/text-editor/editor.tsx +69 -14
- package/src/components/ui/text-editor/extensions.ts +8 -2
- package/src/components/ui/text-editor/highlight-extension.ts +22 -0
- package/src/components/ui/text-editor/tool-bar.tsx +9 -16
- package/src/components/ui/toast.tsx +1 -1
- package/src/components/ui/tu-do/boards/__tests__/board-share-dialog.test.tsx +286 -0
- package/src/components/ui/tu-do/boards/__tests__/task-board-form.test.tsx +12 -0
- package/src/components/ui/tu-do/boards/board-public-link-section.tsx +231 -0
- package/src/components/ui/tu-do/boards/board-share-dialog.tsx +15 -226
- package/src/components/ui/tu-do/boards/board-share-settings-panel.tsx +351 -0
- package/src/components/ui/tu-do/boards/boardId/board-column.tsx +121 -39
- package/src/components/ui/tu-do/boards/boardId/enhanced-task-list.tsx +7 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-clear-delete.ts +2 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-move.ts +5 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-mutations-updates.ts +3 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/bulk/bulk-operation-types.ts +3 -3
- package/src/components/ui/tu-do/boards/boardId/kanban/data/kanban-deadline-query.ts +50 -2
- package/src/components/ui/tu-do/boards/boardId/kanban/data/use-bulk-resources.ts +59 -5
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/__tests__/column-reorder.test.ts +17 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/column-reorder.ts +4 -1
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/drag-preview.tsx +20 -1
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-cache.ts +38 -9
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-drag-order.ts +2 -8
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/task-sort-key.ts +47 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/dnd/use-kanban-dnd.ts +81 -30
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/__tests__/kanban-planner-island.test.tsx +380 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/kanban-planner-dialog.tsx +204 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-digest-panel.tsx +61 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-item-strip.tsx +54 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-plan-toolbar.tsx +251 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-scope-badge.tsx +27 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-section.tsx +58 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-share-dialog.tsx +238 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-target-controls.tsx +143 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/planner-utils.ts +65 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/planner/use-kanban-planner-state.ts +234 -0
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.test.tsx +642 -5
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-columns.tsx +224 -15
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-deadline-panels.tsx +535 -53
- package/src/components/ui/tu-do/boards/boardId/kanban/rendering/kanban-skeleton.tsx +101 -33
- package/src/components/ui/tu-do/boards/boardId/kanban.tsx +235 -113
- package/src/components/ui/tu-do/boards/boardId/task-board-server-page.test.tsx +50 -5
- package/src/components/ui/tu-do/boards/boardId/task-board-server-page.tsx +12 -2
- package/src/components/ui/tu-do/boards/boardId/task-card/measured-task-card.tsx +10 -1
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card-comparator.ts +3 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card-open-options.test.ts +20 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card-open-options.ts +10 -0
- package/src/components/ui/tu-do/boards/boardId/task-card/task-card.tsx +271 -36
- package/src/components/ui/tu-do/boards/boardId/task-filter.test.tsx +152 -0
- package/src/components/ui/tu-do/boards/boardId/task-filter.tsx +555 -545
- package/src/components/ui/tu-do/boards/boardId/task-list.tsx +22 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-grid.tsx +9 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-task-row.tsx +9 -0
- package/src/components/ui/tu-do/boards/boardId/timeline/timeline-toolbar.tsx +9 -0
- package/src/components/ui/tu-do/boards/boardId/timeline-board.tsx +35 -3
- package/src/components/ui/tu-do/boards/form.tsx +1 -1
- package/src/components/ui/tu-do/boards/share-section.tsx +100 -0
- package/src/components/ui/tu-do/drafts/draft-convert-dialog.tsx +10 -12
- package/src/components/ui/tu-do/drafts/drafts-page.tsx +33 -16
- package/src/components/ui/tu-do/hooks/__tests__/useTaskLabelManagement.test.tsx +48 -0
- package/src/components/ui/tu-do/hooks/__tests__/useTaskProjectManagement.test.tsx +144 -0
- package/src/components/ui/tu-do/hooks/useTaskDialog.ts +7 -0
- package/src/components/ui/tu-do/hooks/useTaskLabelManagement.ts +115 -106
- package/src/components/ui/tu-do/hooks/useTaskProjectManagement.ts +115 -122
- package/src/components/ui/tu-do/initiatives/task-initiatives-client.tsx +56 -88
- package/src/components/ui/tu-do/my-tasks/my-tasks-content.tsx +26 -2
- package/src/components/ui/tu-do/my-tasks/use-my-tasks-state.ts +55 -8
- package/src/components/ui/tu-do/notes/note-edit-dialog.tsx +1 -4
- package/src/components/ui/tu-do/progress/task-progress-import-panel.tsx +60 -0
- package/src/components/ui/tu-do/progress/task-progress-leaderboards-panel.tsx +156 -0
- package/src/components/ui/tu-do/progress/task-progress-page.tsx +348 -0
- package/src/components/ui/tu-do/progress/task-progress-panels.tsx +301 -0
- package/src/components/ui/tu-do/providers/task-dialog-provider.tsx +26 -0
- package/src/components/ui/tu-do/shared/__tests__/assignee-select.test.tsx +81 -10
- package/src/components/ui/tu-do/shared/__tests__/board-client.test.tsx +141 -1
- package/src/components/ui/tu-do/shared/__tests__/board-header.test.tsx +377 -36
- package/src/components/ui/tu-do/shared/__tests__/board-switcher.test.tsx +374 -0
- package/src/components/ui/tu-do/shared/__tests__/board-views.test.tsx +419 -5
- package/src/components/ui/tu-do/shared/__tests__/task-board-loading-state.test.tsx +38 -0
- package/src/components/ui/tu-do/shared/__tests__/task-cache-patches.test.ts +147 -0
- package/src/components/ui/tu-do/shared/__tests__/task-legacy-route-recovery.test.tsx +16 -0
- package/src/components/ui/tu-do/shared/__tests__/use-progressive-board-loader.test.tsx +3 -0
- package/src/components/ui/tu-do/shared/assignee-select.tsx +77 -26
- package/src/components/ui/tu-do/shared/board-client.tsx +15 -10
- package/src/components/ui/tu-do/shared/board-config-storage.ts +7 -1
- package/src/components/ui/tu-do/shared/board-header.tsx +471 -975
- package/src/components/ui/tu-do/shared/board-layout-settings.tsx +165 -136
- package/src/components/ui/tu-do/shared/board-switcher.tsx +244 -220
- package/src/components/ui/tu-do/shared/board-user-presence-avatars.tsx +18 -12
- package/src/components/ui/tu-do/shared/board-views.tsx +577 -85
- package/src/components/ui/tu-do/shared/list-view.tsx +246 -2
- package/src/components/ui/tu-do/shared/recycle-bin-panel.tsx +142 -94
- package/src/components/ui/tu-do/shared/special-task-list-pins.ts +51 -0
- package/src/components/ui/tu-do/shared/task-board-loading-state.tsx +28 -0
- package/src/components/ui/tu-do/shared/task-cache-patches.ts +394 -0
- package/src/components/ui/tu-do/shared/task-dialog-manager.tsx +21 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/quick-settings-popover.tsx +5 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-dialog-header.tsx +25 -2
- package/src/components/ui/tu-do/shared/task-edit-dialog/components/task-list-selector.tsx +7 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/field-diff-viewer.tsx +3 -2
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-data.ts +79 -10
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-mutations.ts +76 -77
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-relationships.test.tsx +63 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/hooks/use-task-relationships.ts +78 -69
- package/src/components/ui/tu-do/shared/task-edit-dialog/personal-overrides-section.tsx +28 -8
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/dependencies-section.tsx +14 -3
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/parent-section.tsx +6 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/related-section.tsx +6 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/subtasks-section.tsx +6 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/relationships/types/task-relationships.types.ts +8 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.test.tsx +91 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/selective-revert-panel.tsx +123 -78
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-activity-section.tsx +7 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-dialog-actions.tsx +8 -1
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-properties-section.test.tsx +150 -0
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-properties-section.tsx +61 -35
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-relationships-properties.tsx +44 -2
- package/src/components/ui/tu-do/shared/task-edit-dialog/task-snapshot-dialog.tsx +8 -3
- package/src/components/ui/tu-do/shared/task-edit-dialog.tsx +11 -1
- package/src/components/ui/tu-do/shared/task-legacy-route-recovery.tsx +2 -9
- package/src/components/ui/tu-do/shared/task-row-actions-menu.tsx +11 -0
- package/src/components/ui/tu-do/shared/use-progressive-board-loader.ts +2 -0
- package/src/declarations.d.ts +1 -0
- package/src/hooks/__tests__/use-calendar-readonly.test.tsx +322 -2
- package/src/hooks/__tests__/use-calendar-sync.test.tsx +446 -0
- package/src/hooks/__tests__/useBoardPresence.test.tsx +191 -0
- package/src/hooks/__tests__/useBoardRealtime.test.tsx +24 -144
- package/src/hooks/use-calendar-sync.tsx +247 -243
- package/src/hooks/use-calendar.tsx +323 -138
- package/src/hooks/use-task-actions.ts +24 -0
- package/src/hooks/use-user-workspace-config.ts +75 -0
- package/src/hooks/use-workspace-currency.ts +8 -3
- package/src/hooks/useBoardPresence.ts +364 -0
- package/src/hooks/useBoardRealtimeEventHandler.ts +45 -90
- package/src/lib/workspace-actions.ts +2 -6
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import type { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { createClient } from '@tuturuuu/supabase/next/client';
|
|
3
2
|
import type { Task } from '@tuturuuu/types/primitives/Task';
|
|
4
3
|
import type { TaskList } from '@tuturuuu/types/primitives/TaskList';
|
|
5
4
|
import { DEV_MODE } from '@tuturuuu/utils/constants';
|
|
6
5
|
import { useCallback, useEffect, useRef } from 'react';
|
|
7
6
|
import type { BoardRealtimePayload } from './useBoardRealtime.types';
|
|
8
7
|
|
|
9
|
-
type TaskRelationRow = {
|
|
10
|
-
id: string;
|
|
11
|
-
assignees?: Array<{ user: NonNullable<Task['assignees']>[number] | null }>;
|
|
12
|
-
labels?: Array<{ label: NonNullable<Task['labels']>[number] | null }>;
|
|
13
|
-
projects?: Array<{ project: NonNullable<Task['projects']>[number] | null }>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
8
|
type CallbackRef<T> = {
|
|
17
9
|
current: T | undefined;
|
|
18
10
|
};
|
|
@@ -30,9 +22,6 @@ type UseBoardRealtimeEventHandlerOptions = {
|
|
|
30
22
|
onTaskRelationsChangeRef?: CallbackRef<(taskIds: string[]) => void>;
|
|
31
23
|
};
|
|
32
24
|
|
|
33
|
-
const isDefined = <T>(value: T | null | undefined): value is T =>
|
|
34
|
-
value !== null && value !== undefined;
|
|
35
|
-
|
|
36
25
|
function mergeRealtimeTask(
|
|
37
26
|
old: Task[] | undefined,
|
|
38
27
|
taskData: Partial<Task> & { id: string }
|
|
@@ -188,10 +177,35 @@ function invalidateTaskMembershipQueries(
|
|
|
188
177
|
void queryClient.invalidateQueries({
|
|
189
178
|
queryKey: ['task-list-counts', boardId],
|
|
190
179
|
});
|
|
180
|
+
void queryClient.invalidateQueries({
|
|
181
|
+
predicate: (query) => {
|
|
182
|
+
const queryKey = query.queryKey;
|
|
183
|
+
return (
|
|
184
|
+
Array.isArray(queryKey) &&
|
|
185
|
+
queryKey[0] === 'kanban-deadline-tasks' &&
|
|
186
|
+
queryKey[2] === boardId
|
|
187
|
+
);
|
|
188
|
+
},
|
|
189
|
+
});
|
|
191
190
|
void queryClient.invalidateQueries({ queryKey: ['my-tasks'] });
|
|
192
191
|
void queryClient.invalidateQueries({ queryKey: ['my-completed-tasks'] });
|
|
193
192
|
}
|
|
194
193
|
|
|
194
|
+
function invalidateTaskRelationQueries(
|
|
195
|
+
queryClient: QueryClient,
|
|
196
|
+
boardId: string,
|
|
197
|
+
taskIds: string[]
|
|
198
|
+
) {
|
|
199
|
+
void queryClient.invalidateQueries({
|
|
200
|
+
predicate: (query) =>
|
|
201
|
+
Array.isArray(query.queryKey) &&
|
|
202
|
+
query.queryKey[0] === 'workspaceTask' &&
|
|
203
|
+
typeof query.queryKey[2] === 'string' &&
|
|
204
|
+
taskIds.includes(query.queryKey[2]),
|
|
205
|
+
});
|
|
206
|
+
invalidateTaskMembershipQueries(queryClient, boardId);
|
|
207
|
+
}
|
|
208
|
+
|
|
195
209
|
export function useBoardRealtimeEventHandler({
|
|
196
210
|
boardId,
|
|
197
211
|
queryClient,
|
|
@@ -201,90 +215,27 @@ export function useBoardRealtimeEventHandler({
|
|
|
201
215
|
onTaskRelationsChangeRef,
|
|
202
216
|
}: UseBoardRealtimeEventHandlerOptions) {
|
|
203
217
|
// Collects task IDs from task:relations-changed events over 150ms
|
|
204
|
-
// and
|
|
218
|
+
// and reconciles relation-bearing queries together. Visible board task arrays
|
|
219
|
+
// stay patched in place by the sender and by board background revalidation.
|
|
205
220
|
const pendingRelationIdsRef = useRef<Set<string>>(new Set());
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
);
|
|
221
|
+
const relationInvalidationTimerRef = useRef<ReturnType<
|
|
222
|
+
typeof setTimeout
|
|
223
|
+
> | null>(null);
|
|
209
224
|
|
|
210
|
-
const
|
|
211
|
-
|
|
225
|
+
const invalidateBatchedRelations = useCallback(() => {
|
|
226
|
+
relationInvalidationTimerRef.current = null;
|
|
212
227
|
const taskIds = [...pendingRelationIdsRef.current];
|
|
213
228
|
pendingRelationIdsRef.current.clear();
|
|
214
229
|
if (taskIds.length === 0) return;
|
|
215
230
|
|
|
216
231
|
if (DEV_MODE) {
|
|
217
232
|
console.log(
|
|
218
|
-
`[useBoardRealtime]
|
|
233
|
+
`[useBoardRealtime] Reconciling relations for ${taskIds.length} task(s):`,
|
|
219
234
|
taskIds
|
|
220
235
|
);
|
|
221
236
|
}
|
|
222
237
|
|
|
223
|
-
|
|
224
|
-
const supabase = createClient();
|
|
225
|
-
const { data, error } = await supabase
|
|
226
|
-
.from('tasks')
|
|
227
|
-
.select(
|
|
228
|
-
`
|
|
229
|
-
id,
|
|
230
|
-
assignees:task_assignees(
|
|
231
|
-
user:users(id, display_name, avatar_url)
|
|
232
|
-
),
|
|
233
|
-
labels:task_labels(
|
|
234
|
-
label:workspace_task_labels(id, name, color, created_at)
|
|
235
|
-
),
|
|
236
|
-
projects:task_project_tasks(
|
|
237
|
-
project:task_projects(id, name, status)
|
|
238
|
-
)
|
|
239
|
-
`
|
|
240
|
-
)
|
|
241
|
-
.in('id', taskIds);
|
|
242
|
-
|
|
243
|
-
if (error || !data) {
|
|
244
|
-
if (DEV_MODE) {
|
|
245
|
-
console.error(
|
|
246
|
-
'[useBoardRealtime] Failed to batch-fetch relations:',
|
|
247
|
-
error
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const relationsMap = new Map<
|
|
254
|
-
string,
|
|
255
|
-
{
|
|
256
|
-
assignees: NonNullable<Task['assignees']>;
|
|
257
|
-
labels: NonNullable<Task['labels']>;
|
|
258
|
-
projects: NonNullable<Task['projects']>;
|
|
259
|
-
}
|
|
260
|
-
>();
|
|
261
|
-
for (const d of data as TaskRelationRow[]) {
|
|
262
|
-
relationsMap.set(d.id, {
|
|
263
|
-
assignees: d.assignees?.map((a) => a.user).filter(isDefined) || [],
|
|
264
|
-
labels: d.labels?.map((l) => l.label).filter(isDefined) || [],
|
|
265
|
-
projects: d.projects?.map((p) => p.project).filter(isDefined) || [],
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
updateBoardTaskCaches(queryClient, boardId, (old) => {
|
|
270
|
-
if (!old) return old;
|
|
271
|
-
return old.map((task) => {
|
|
272
|
-
const relations = relationsMap.get(task.id);
|
|
273
|
-
return relations ? { ...task, ...relations } : task;
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
for (const [taskId, relations] of relationsMap.entries()) {
|
|
277
|
-
patchWorkspaceTaskCaches(queryClient, { id: taskId, ...relations });
|
|
278
|
-
patchMyTasksCaches(queryClient, { id: taskId, ...relations });
|
|
279
|
-
}
|
|
280
|
-
} catch (err) {
|
|
281
|
-
if (DEV_MODE) {
|
|
282
|
-
console.error(
|
|
283
|
-
'[useBoardRealtime] Error batch-fetching relations:',
|
|
284
|
-
err
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
238
|
+
invalidateTaskRelationQueries(queryClient, boardId, taskIds);
|
|
288
239
|
}, [boardId, queryClient]);
|
|
289
240
|
|
|
290
241
|
const handleBoardRealtimeEvent = useCallback(
|
|
@@ -342,6 +293,7 @@ export function useBoardRealtimeEventHandler({
|
|
|
342
293
|
patchMyTasksCaches(queryClient, taskData);
|
|
343
294
|
if (
|
|
344
295
|
'list_id' in taskData ||
|
|
296
|
+
'end_date' in taskData ||
|
|
345
297
|
'completed' in taskData ||
|
|
346
298
|
'completed_at' in taskData ||
|
|
347
299
|
'closed_at' in taskData ||
|
|
@@ -453,10 +405,13 @@ export function useBoardRealtimeEventHandler({
|
|
|
453
405
|
onTaskRelationsChangeRef?.current?.(ids);
|
|
454
406
|
}
|
|
455
407
|
|
|
456
|
-
if (
|
|
457
|
-
clearTimeout(
|
|
408
|
+
if (relationInvalidationTimerRef.current) {
|
|
409
|
+
clearTimeout(relationInvalidationTimerRef.current);
|
|
458
410
|
}
|
|
459
|
-
|
|
411
|
+
relationInvalidationTimerRef.current = setTimeout(
|
|
412
|
+
invalidateBatchedRelations,
|
|
413
|
+
150
|
|
414
|
+
);
|
|
460
415
|
return;
|
|
461
416
|
}
|
|
462
417
|
|
|
@@ -474,7 +429,7 @@ export function useBoardRealtimeEventHandler({
|
|
|
474
429
|
},
|
|
475
430
|
[
|
|
476
431
|
boardId,
|
|
477
|
-
|
|
432
|
+
invalidateBatchedRelations,
|
|
478
433
|
onListChangeRef,
|
|
479
434
|
onTaskRelationsChangeRef,
|
|
480
435
|
onTaskChangeRef,
|
|
@@ -485,9 +440,9 @@ export function useBoardRealtimeEventHandler({
|
|
|
485
440
|
|
|
486
441
|
useEffect(() => {
|
|
487
442
|
return () => {
|
|
488
|
-
if (
|
|
489
|
-
clearTimeout(
|
|
490
|
-
|
|
443
|
+
if (relationInvalidationTimerRef.current) {
|
|
444
|
+
clearTimeout(relationInvalidationTimerRef.current);
|
|
445
|
+
relationInvalidationTimerRef.current = null;
|
|
491
446
|
}
|
|
492
447
|
pendingRelationIdsRef.current.clear();
|
|
493
448
|
};
|
|
@@ -403,13 +403,9 @@ export async function fetchWorkspaceSummaries({
|
|
|
403
403
|
|
|
404
404
|
guestWorkspaceById.set(workspaceId, {
|
|
405
405
|
id: workspaceId,
|
|
406
|
-
name: workspace?.personal
|
|
407
|
-
? displayLabel || workspace?.name || 'Personal'
|
|
408
|
-
: workspace?.name || 'Untitled',
|
|
406
|
+
name: workspace?.name || (workspace?.personal ? 'Personal' : 'Untitled'),
|
|
409
407
|
personal: workspace?.personal ?? false,
|
|
410
|
-
avatar_url: workspace?.
|
|
411
|
-
? userAvatarUrl || workspace?.avatar_url || null
|
|
412
|
-
: workspace?.avatar_url || null,
|
|
408
|
+
avatar_url: workspace?.avatar_url || null,
|
|
413
409
|
logo_url: workspace?.logo_url || null,
|
|
414
410
|
created_by_me: workspace?.creator_id === userId,
|
|
415
411
|
tier: resolveWorkspaceTier(workspace ?? {}, productTiersById),
|