Browse Source

fix(update-activity): Fix updateActivty for groupStore (#57412)

Fixes [#47818](https://github.com/getsentry/sentry/issues/47818)
Jordan Luse 1 year ago
parent
commit
f8ff7b9e47

+ 2 - 2
static/app/actionCreators/group.tsx

@@ -188,7 +188,7 @@ export function updateNote(
   id: string,
   oldText: string
 ) {
-  GroupStore.updateActivity(group.id, id, {data: {text: note.text}});
+  GroupStore.updateActivity(group.id, id, {text: note.text});
 
   const promise = api.requestPromise(
     `/organizations/${orgSlug}/issues/${group.id}/comments/${id}/`,
@@ -198,7 +198,7 @@ export function updateNote(
     }
   );
 
-  promise.catch(() => GroupStore.updateActivity(group.id, id, {data: {text: oldText}}));
+  promise.catch(() => GroupStore.updateActivity(group.id, id, {text: oldText}));
 
   return promise;
 }

+ 23 - 1
static/app/stores/groupStore.spec.tsx

@@ -1,5 +1,7 @@
+import {Project} from 'sentry-fixture/project';
+
 import GroupStore from 'sentry/stores/groupStore';
-import {Group, GroupStats, TimeseriesValue} from 'sentry/types';
+import {Group, GroupActivityType, GroupStats, TimeseriesValue} from 'sentry/types';
 
 const MOCK_PROJECT = TestStubs.Project();
 
@@ -227,5 +229,25 @@ describe('GroupStore', function () {
         expect(GroupStore.items[0]).toEqual(assignedGroup);
       });
     });
+
+    describe('updateActivity()', function () {
+      it("should update activity data text'", function () {
+        GroupStore.items = [
+          g('1', {
+            activity: [
+              {
+                id: '1',
+                type: GroupActivityType.NOTE,
+                dateCreated: '',
+                project: Project(),
+                data: {text: 'Orginal Text'},
+              },
+            ],
+          }),
+        ];
+        GroupStore.updateActivity('1', '1', {text: 'Updated Text'});
+        expect(GroupStore.items[0].activity[0].data).toEqual({text: 'Updated Text'});
+      });
+    });
   });
 });

+ 1 - 1
static/app/stores/groupStore.tsx

@@ -33,7 +33,7 @@ interface InternalDefinition {
   pendingChanges: Map<ChangeId, Change>;
   removeActivity: (groupId: string, id: string) => number;
   statuses: Record<string, Record<string, boolean>>;
-  updateActivity: (groupId: string, id: string, data: Partial<Activity>) => void;
+  updateActivity: (groupId: string, id: string, data: Partial<Activity['data']>) => void;
   updateItems: (itemIds: ItemIds) => void;
 }