RichText editor fixes (#15678)
closes https://github.com/twentyhq/twenty/issues/15474 closes https://github.com/twentyhq/twenty/issues/15677
This commit is contained in:
@@ -26,6 +26,7 @@ import { SIDE_PANEL_FOCUS_ID } from '@/command-menu/constants/SidePanelFocusId';
|
||||
import { useApolloCoreClient } from '@/object-metadata/hooks/useApolloCoreClient';
|
||||
import { useLabelIdentifierFieldMetadataItem } from '@/object-metadata/hooks/useLabelIdentifierFieldMetadataItem';
|
||||
import { useDeleteManyRecords } from '@/object-record/hooks/useDeleteManyRecords';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { useLazyFetchAllRecords } from '@/object-record/hooks/useLazyFetchAllRecords';
|
||||
import { useRestoreManyRecords } from '@/object-record/hooks/useRestoreManyRecords';
|
||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
@@ -83,6 +84,24 @@ export const ActivityRichTextEditor = ({
|
||||
const { removeFocusItemFromFocusStackById } =
|
||||
useRemoveFocusItemFromFocusStackById();
|
||||
|
||||
const { records: attachments } = useFindManyRecords<Attachment>({
|
||||
objectNameSingular: CoreObjectNameSingular.Attachment,
|
||||
filter: {
|
||||
or: [
|
||||
{
|
||||
noteId: {
|
||||
eq: activityId,
|
||||
},
|
||||
},
|
||||
{
|
||||
taskId: {
|
||||
eq: activityId,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const { fetchAllRecords: findSoftDeletedAttachments } =
|
||||
useLazyFetchAllRecords({
|
||||
objectNameSingular: CoreObjectNameSingular.Attachment,
|
||||
@@ -208,7 +227,7 @@ export const ActivityRichTextEditor = ({
|
||||
|
||||
const attachmentIdsToDelete = getActivityAttachmentIdsToDelete(
|
||||
newStringifiedBody,
|
||||
oldActivity?.attachments,
|
||||
attachments,
|
||||
oldActivity?.bodyV2.blocknote,
|
||||
);
|
||||
|
||||
@@ -220,7 +239,7 @@ export const ActivityRichTextEditor = ({
|
||||
|
||||
const attachmentPathsToRestore = getActivityAttachmentPathsToRestore(
|
||||
newStringifiedBody,
|
||||
oldActivity?.attachments,
|
||||
attachments,
|
||||
);
|
||||
|
||||
if (attachmentPathsToRestore.length > 0) {
|
||||
@@ -238,7 +257,7 @@ export const ActivityRichTextEditor = ({
|
||||
}
|
||||
const attachmentsToUpdate = getActivityAttachmentIdsAndNameToUpdate(
|
||||
newStringifiedBody,
|
||||
oldActivity?.attachments,
|
||||
attachments,
|
||||
);
|
||||
if (attachmentsToUpdate.length > 0) {
|
||||
for (const attachmentToUpdate of attachmentsToUpdate) {
|
||||
@@ -251,6 +270,7 @@ export const ActivityRichTextEditor = ({
|
||||
}
|
||||
},
|
||||
[
|
||||
attachments,
|
||||
activityId,
|
||||
cache,
|
||||
objectMetadataItemActivity,
|
||||
|
||||
+9
-4
@@ -67,11 +67,16 @@ export class CommonCreateOneQueryRunnerService extends CommonBaseQueryRunnerServ
|
||||
|
||||
async processQueryResult(
|
||||
queryResult: ObjectRecord,
|
||||
_objectMetadataItemId: string,
|
||||
_objectMetadataMaps: ObjectMetadataMaps,
|
||||
_authContext: WorkspaceAuthContext,
|
||||
objectMetadataItemId: string,
|
||||
objectMetadataMaps: ObjectMetadataMaps,
|
||||
authContext: WorkspaceAuthContext,
|
||||
): Promise<ObjectRecord> {
|
||||
return queryResult;
|
||||
return this.commonResultGettersService.processRecord(
|
||||
queryResult,
|
||||
objectMetadataItemId,
|
||||
objectMetadataMaps,
|
||||
authContext.workspace.id,
|
||||
);
|
||||
}
|
||||
|
||||
async validate(
|
||||
|
||||
+9
-4
@@ -67,11 +67,16 @@ export class CommonDeleteOneQueryRunnerService extends CommonBaseQueryRunnerServ
|
||||
|
||||
async processQueryResult(
|
||||
queryResult: ObjectRecord,
|
||||
_objectMetadataItemId: string,
|
||||
_objectMetadataMaps: ObjectMetadataMaps,
|
||||
_authContext: WorkspaceAuthContext,
|
||||
objectMetadataItemId: string,
|
||||
objectMetadataMaps: ObjectMetadataMaps,
|
||||
authContext: WorkspaceAuthContext,
|
||||
): Promise<ObjectRecord> {
|
||||
return queryResult;
|
||||
return this.commonResultGettersService.processRecord(
|
||||
queryResult,
|
||||
objectMetadataItemId,
|
||||
objectMetadataMaps,
|
||||
authContext.workspace.id,
|
||||
);
|
||||
}
|
||||
|
||||
async validate(
|
||||
|
||||
+9
-4
@@ -65,11 +65,16 @@ export class CommonDestroyOneQueryRunnerService extends CommonBaseQueryRunnerSer
|
||||
|
||||
async processQueryResult(
|
||||
queryResult: ObjectRecord,
|
||||
_objectMetadataItemId: string,
|
||||
_objectMetadataMaps: ObjectMetadataMaps,
|
||||
_authContext: WorkspaceAuthContext,
|
||||
objectMetadataItemId: string,
|
||||
objectMetadataMaps: ObjectMetadataMaps,
|
||||
authContext: WorkspaceAuthContext,
|
||||
): Promise<ObjectRecord> {
|
||||
return queryResult;
|
||||
return this.commonResultGettersService.processRecord(
|
||||
queryResult,
|
||||
objectMetadataItemId,
|
||||
objectMetadataMaps,
|
||||
authContext.workspace.id,
|
||||
);
|
||||
}
|
||||
|
||||
async validate(
|
||||
|
||||
+9
-4
@@ -67,11 +67,16 @@ export class CommonRestoreOneQueryRunnerService extends CommonBaseQueryRunnerSer
|
||||
|
||||
async processQueryResult(
|
||||
queryResult: ObjectRecord,
|
||||
_objectMetadataItemId: string,
|
||||
_objectMetadataMaps: ObjectMetadataMaps,
|
||||
_authContext: WorkspaceAuthContext,
|
||||
objectMetadataItemId: string,
|
||||
objectMetadataMaps: ObjectMetadataMaps,
|
||||
authContext: WorkspaceAuthContext,
|
||||
): Promise<ObjectRecord> {
|
||||
return queryResult;
|
||||
return this.commonResultGettersService.processRecord(
|
||||
queryResult,
|
||||
objectMetadataItemId,
|
||||
objectMetadataMaps,
|
||||
authContext.workspace.id,
|
||||
);
|
||||
}
|
||||
|
||||
async validate(
|
||||
|
||||
+9
-4
@@ -77,11 +77,16 @@ export class CommonUpdateOneQueryRunnerService extends CommonBaseQueryRunnerServ
|
||||
|
||||
async processQueryResult(
|
||||
queryResult: ObjectRecord,
|
||||
_objectMetadataItemId: string,
|
||||
_objectMetadataMaps: ObjectMetadataMaps,
|
||||
_authContext: WorkspaceAuthContext,
|
||||
objectMetadataItemId: string,
|
||||
objectMetadataMaps: ObjectMetadataMaps,
|
||||
authContext: WorkspaceAuthContext,
|
||||
): Promise<ObjectRecord> {
|
||||
return queryResult;
|
||||
return this.commonResultGettersService.processRecord(
|
||||
queryResult,
|
||||
objectMetadataItemId,
|
||||
objectMetadataMaps,
|
||||
authContext.workspace.id,
|
||||
);
|
||||
}
|
||||
|
||||
async validate(
|
||||
|
||||
Reference in New Issue
Block a user