diff --git a/packages/client/mutations/AutogroupMutation.ts b/packages/client/mutations/AutogroupMutation.ts index 8f05c4d042c..3a66969a2e1 100644 --- a/packages/client/mutations/AutogroupMutation.ts +++ b/packages/client/mutations/AutogroupMutation.ts @@ -13,6 +13,7 @@ graphql` reflectionGroups { id title + smartTitle reflections { id plaintextContent diff --git a/packages/server/graphql/mutations/helpers/updateGroupTitle.ts b/packages/server/graphql/mutations/helpers/updateGroupTitle.ts index 658c8b84569..3ebe85bdf3d 100644 --- a/packages/server/graphql/mutations/helpers/updateGroupTitle.ts +++ b/packages/server/graphql/mutations/helpers/updateGroupTitle.ts @@ -15,6 +15,7 @@ type Input = { } const updateGroupTitle = async (input: Input) => { + console.log('in update group...') const {reflections, reflectionGroupId, meetingId, teamId, dataLoader} = input if (reflections.length === 1) { // For single reflection, use its content as the title diff --git a/packages/server/graphql/mutations/helpers/updateReflectionLocation/addReflectionToGroup.ts b/packages/server/graphql/mutations/helpers/updateReflectionLocation/addReflectionToGroup.ts index 29f5df88c5c..672e287ccd2 100644 --- a/packages/server/graphql/mutations/helpers/updateReflectionLocation/addReflectionToGroup.ts +++ b/packages/server/graphql/mutations/helpers/updateReflectionLocation/addReflectionToGroup.ts @@ -2,6 +2,7 @@ import dndNoise from 'parabol-client/utils/dndNoise' import getKysely from '../../../../postgres/getKysely' import updateGroupTitle from '../updateGroupTitle' import {GQLContext} from './../../../graphql' +import updateSmartGroupTitle from './updateSmartGroupTitle' const addReflectionToGroup = async ( reflectionId: string, @@ -14,10 +15,9 @@ const addReflectionToGroup = async ( const reflection = await dataLoader.get('retroReflections').load(reflectionId) if (!reflection) throw new Error('Reflection not found') const {reflectionGroupId: oldReflectionGroupId, meetingId: reflectionMeetingId} = reflection - const [reflectionGroup, oldReflectionGroup] = await Promise.all([ - dataLoader.get('retroReflectionGroups').loadNonNull(reflectionGroupId), - dataLoader.get('retroReflectionGroups').loadNonNull(oldReflectionGroupId) - ]) + const reflectionGroup = await dataLoader + .get('retroReflectionGroups') + .loadNonNull(reflectionGroupId) dataLoader.get('retroReflectionGroups').clear(reflectionGroupId) dataLoader.get('retroReflectionGroups').clear(oldReflectionGroupId) @@ -56,17 +56,11 @@ const addReflectionToGroup = async ( .get('retroReflectionsByGroupId') .load(oldReflectionGroupId) - const oldGroupHasSingleReflectionCustomTitle = - oldReflectionGroup.title !== oldReflectionGroup.smartTitle && oldReflections.length === 0 - const newGroupHasSmartTitle = reflectionGroup.title === reflectionGroup.smartTitle - - if (oldGroupHasSingleReflectionCustomTitle && newGroupHasSmartTitle) { - // Edge case of dragging a single card with a custom group name on a group with smart name - await pg - .updateTable('RetroReflectionGroup') - .set({title: oldReflectionGroup.title, smartTitle: smartTitle ?? ''}) - .where('id', '=', reflectionGroupId) - .execute() + if (smartTitle) { + // smartTitle exists when autogrouping or resetting groups + await updateSmartGroupTitle(reflectionGroupId, smartTitle) + reflectionGroup.smartTitle = smartTitle + reflectionGroup.title = smartTitle } else { const meeting = await dataLoader.get('newMeetings').loadNonNull(meetingId) await updateGroupTitle({