@fluid-app/portal-sdk 0.1.757 → 0.1.758

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.
@@ -39251,15 +39251,9 @@ function useSaveDraft(conversationId, options) {
39251
39251
  if (!result) return;
39252
39252
  queryClient.setQueryData(MESSAGES_QUERY_KEYS.draft(conversationId), (current) => {
39253
39253
  if (!current) return current;
39254
- let updatedFiles = [...current.files];
39255
- if (typeof result === "object" && result !== null && "attachments" in result && Array.isArray(result.attachments)) updatedFiles = updatedFiles.filter((file) => {
39256
- return file.status !== "failed";
39257
- });
39258
- else updatedFiles = [];
39259
39254
  const lastUpdatedAt = typeof result === "object" && result !== null && "updated_at" in result ? result.updated_at ?? null : null;
39260
39255
  return {
39261
39256
  ...current,
39262
- files: updatedFiles,
39263
39257
  lastUpdatedAt
39264
39258
  };
39265
39259
  });
@@ -56144,8 +56138,26 @@ function convertMentionTokensInJson(node, users) {
56144
56138
  //#region ../../messaging/ui/src/components/composer/useComposerActions.ts
56145
56139
  function useComposerActions({ editor, onSend, onSaveScheduledEdit, isUploadingFiles, completedFiles, clearDebounce, saveImmediately, draft, mode, sendWithEnter, conversationType, conversationId, onScheduleSuccess, onScheduleComplete, onScheduleError }) {
56146
56140
  const api = useMessagingApi();
56141
+ const isSendingRef = useRef(false);
56142
+ const canSend = conversationId > 0;
56143
+ const cleanupAfterSuccess = useCallback((markdown, sentFiles) => {
56144
+ sentFiles.forEach((file) => draft.removeFile(file.client_id));
56145
+ if (editor?.storage.markdown.getMarkdown() === markdown) {
56146
+ editor.commands.clearContent();
56147
+ draft.setBody("");
56148
+ }
56149
+ saveImmediately().catch((error) => {
56150
+ console.error("Failed to save draft after composer action:", error);
56151
+ });
56152
+ }, [
56153
+ draft,
56154
+ editor,
56155
+ saveImmediately
56156
+ ]);
56147
56157
  const handleSend = useCallback(async () => {
56158
+ if (isSendingRef.current) return;
56148
56159
  if (!editor || !onSend) return;
56160
+ if (!canSend) return;
56149
56161
  if (isUploadingFiles) return;
56150
56162
  clearDebounce();
56151
56163
  const markdown = editor.storage.markdown.getMarkdown();
@@ -56158,25 +56170,30 @@ function useComposerActions({ editor, onSend, onSaveScheduledEdit, isUploadingFi
56158
56170
  content_size: file.content_size,
56159
56171
  metadata: file.metadata ?? void 0
56160
56172
  }));
56161
- draft.clearDraft();
56162
- editor.commands.clearContent();
56163
- if (mode === "editScheduled" && onSaveScheduledEdit) onSaveScheduledEdit(markdown, attachments);
56164
- else if (onSend) onSend(markdown, attachments);
56165
- saveImmediately().catch((error) => {
56166
- console.error("Failed to save empty draft after send:", error);
56167
- });
56173
+ isSendingRef.current = true;
56174
+ try {
56175
+ if (mode === "editScheduled" && onSaveScheduledEdit) await onSaveScheduledEdit(markdown, attachments);
56176
+ else await onSend(markdown, attachments);
56177
+ } catch (error) {
56178
+ console.error("Failed to send message from composer:", error);
56179
+ return;
56180
+ } finally {
56181
+ isSendingRef.current = false;
56182
+ }
56183
+ cleanupAfterSuccess(markdown, completedFiles);
56168
56184
  }, [
56169
56185
  editor,
56170
56186
  onSend,
56171
56187
  onSaveScheduledEdit,
56172
56188
  isUploadingFiles,
56173
56189
  completedFiles,
56174
- saveImmediately,
56175
- draft,
56190
+ cleanupAfterSuccess,
56176
56191
  mode,
56177
- clearDebounce
56192
+ clearDebounce,
56193
+ canSend
56178
56194
  ]);
56179
56195
  return {
56196
+ canSend,
56180
56197
  handleSend,
56181
56198
  handleKeyDown: useCallback((event) => {
56182
56199
  if (mode === "editScheduled") return;
@@ -56195,6 +56212,7 @@ function useComposerActions({ editor, onSend, onSaveScheduledEdit, isUploadingFi
56195
56212
  ]),
56196
56213
  handleSchedule: useCallback(async (scheduledAt) => {
56197
56214
  if (!editor) return;
56215
+ if (!canSend) return;
56198
56216
  if (isUploadingFiles) return;
56199
56217
  clearDebounce();
56200
56218
  const markdown = editor.storage.markdown.getMarkdown();
@@ -56227,11 +56245,7 @@ function useComposerActions({ editor, onSend, onSaveScheduledEdit, isUploadingFi
56227
56245
  metadata: a.metadata ?? void 0
56228
56246
  }))
56229
56247
  } });
56230
- draft.clearDraft();
56231
- editor.commands.clearContent();
56232
- saveImmediately().catch((error) => {
56233
- console.error("Failed to save empty draft after schedule:", error);
56234
- });
56248
+ cleanupAfterSuccess(markdown, completedFiles);
56235
56249
  onScheduleSuccess?.(scheduledAt);
56236
56250
  onScheduleComplete?.();
56237
56251
  } catch (error) {
@@ -56240,13 +56254,13 @@ function useComposerActions({ editor, onSend, onSaveScheduledEdit, isUploadingFi
56240
56254
  }
56241
56255
  }, [
56242
56256
  editor,
56257
+ canSend,
56243
56258
  isUploadingFiles,
56244
56259
  completedFiles,
56245
56260
  conversationId,
56246
56261
  conversationType,
56247
56262
  api,
56248
- draft,
56249
- saveImmediately,
56263
+ cleanupAfterSuccess,
56250
56264
  onScheduleSuccess,
56251
56265
  onScheduleComplete,
56252
56266
  onScheduleError,
@@ -56373,7 +56387,7 @@ function MessageComposer({ onSend, onScheduleSuccess, onSaveScheduledEdit, place
56373
56387
  editor,
56374
56388
  mentionableUsers
56375
56389
  ]);
56376
- const { handleSend, handleKeyDown, handleSchedule } = useComposerActions({
56390
+ const { canSend, handleSend, handleKeyDown, handleSchedule } = useComposerActions({
56377
56391
  editor,
56378
56392
  onSend,
56379
56393
  onSaveScheduledEdit,
@@ -56427,7 +56441,7 @@ function MessageComposer({ onSend, onScheduleSuccess, onSaveScheduledEdit, place
56427
56441
  onSchedule: handleSchedule,
56428
56442
  messageHasContent: hasContent,
56429
56443
  canMentionUsers: !!mentionableUsers && mentionableUsers.length > 0,
56430
- canSendMessage: hasContent && !isUploadingFiles && !disabled,
56444
+ canSendMessage: canSend && hasContent && !isUploadingFiles && !disabled,
56431
56445
  mode,
56432
56446
  onSaveEdit: mode === "editScheduled" ? handleSend : void 0,
56433
56447
  canSchedule,
@@ -56918,7 +56932,7 @@ function MessagesView({ conversationId, messageId, saveDrafts, noDateResults, re
56918
56932
  setEntryUnreadBaselineId(null);
56919
56933
  baselineCapturedRef.current = true;
56920
56934
  unresolvedBaselineOrdinalRef.current = 0;
56921
- sendMessageMutation.mutate({
56935
+ return sendMessageMutation.mutateAsync({
56922
56936
  body,
56923
56937
  attachments
56924
56938
  });
@@ -56929,8 +56943,8 @@ function MessagesView({ conversationId, messageId, saveDrafts, noDateResults, re
56929
56943
  sendMessageMutation
56930
56944
  ]);
56931
56945
  const handleSaveScheduledEdit = useCallback(async (body, attachments = []) => {
56932
- if (!isEditingScheduled || !conversationMetadata) return;
56933
- updateScheduledMutation.mutate({
56946
+ if (!isEditingScheduled || !conversationMetadata) throw new Error("Scheduled message edit is not ready to save");
56947
+ return updateScheduledMutation.mutateAsync({
56934
56948
  body,
56935
56949
  attachments
56936
56950
  });
@@ -56983,8 +56997,7 @@ function MessagesView({ conversationId, messageId, saveDrafts, noDateResults, re
56983
56997
  onSend: handleSend,
56984
56998
  onSaveScheduledEdit: handleSaveScheduledEdit,
56985
56999
  onScheduleSuccess: handleScheduleSuccess
56986
- });
56987
- if (isLoading) return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(MessagingLoadingSkeleton, { label: t("loading_messaging") }), /* @__PURE__ */ jsx("div", { children: composer }, "layer-2")] }, "layer-1");
57000
+ }, "composer-input");
56988
57001
  if (isError || metadataError) {
56989
57002
  const metaNotFound = metadataError && "status" in metadataError && metadataError.status === 404;
56990
57003
  const messagesNotFound = messagesError && "status" in messagesError && messagesError.status === 404;
@@ -56997,7 +57010,7 @@ function MessagesView({ conversationId, messageId, saveDrafts, noDateResults, re
56997
57010
  }
56998
57011
  return /* @__PURE__ */ jsxs("div", {
56999
57012
  className: "flex h-full min-h-0 flex-col",
57000
- children: [/* @__PURE__ */ jsxs(AnchoredItems, {
57013
+ children: [isLoading ? /* @__PURE__ */ jsx(MessagingLoadingSkeleton, { label: t("loading_messaging") }) : /* @__PURE__ */ jsxs(AnchoredItems, {
57001
57014
  scrollerRef,
57002
57015
  scrollToKeyOnce: messageId ? `id:${messageId}` : void 0,
57003
57016
  onCorrection: (correctionAmount) => issueCorrection(correctionAmount),
@@ -57076,15 +57089,15 @@ function MessagesView({ conversationId, messageId, saveDrafts, noDateResults, re
57076
57089
  }, "watcher-bottom")
57077
57090
  ]
57078
57091
  }), /* @__PURE__ */ jsxs("div", {
57079
- className: "from-background sticky bottom-0 z-40 flex-shrink-0 bg-gradient-to-t to-transparent",
57092
+ className: isLoading ? void 0 : "from-background sticky bottom-0 z-40 flex-shrink-0 bg-gradient-to-t to-transparent",
57080
57093
  children: [
57081
- /* @__PURE__ */ jsx(MessagesViewScheduledBanner, {
57094
+ !isLoading && /* @__PURE__ */ jsx(MessagesViewScheduledBanner, {
57082
57095
  optimisticScheduled,
57083
57096
  scheduledData,
57084
57097
  isEditingScheduled,
57085
57098
  renderScheduledBanner
57086
57099
  }),
57087
- hasNewMessages && /* @__PURE__ */ jsx("div", {
57100
+ !isLoading && hasNewMessages && /* @__PURE__ */ jsx("div", {
57088
57101
  className: "pointer-events-auto absolute bottom-full mb-2 flex w-full justify-center",
57089
57102
  children: /* @__PURE__ */ jsxs("button", {
57090
57103
  type: "button",
@@ -58648,4 +58661,4 @@ const messagingScreenPropertySchema = {
58648
58661
  //#endregion
58649
58662
  export { BottomNavVisibilityProvider as a, useMessagingAuth as i, messagingScreenPropertySchema as n, useBottomNavHidden as o, useMessagingConfig as r, MessagingScreen as t };
58650
58663
 
58651
- //# sourceMappingURL=MessagingScreen-CnwSwV_P.mjs.map
58664
+ //# sourceMappingURL=MessagingScreen-V95LvJRO.mjs.map