Commit 2fbc462
authored
feat(bug reports): Optimistically update the feedback items mutation is finished (#58973)
When you're doing a any mutation we're going to optimistically update
any feedback items that are in the useApiQuery cache or the
useFetchFeedbackInfiniteListData cache. This means the list on the left,
and the visible item on the right.
Steps to see it in action:
1. Click to view the first feedback in the list to open it on the right
side
2. Click the checkboxes for the first 3 feedback items in the list
(including the one you have open)
3. Click "Mark all as read" or "unread" bulk operation
Notice that the visible feedback on the right side of the screen will
update immediately to reflect the new state.
Along the way I was able to re-combine the bulk-mutation helper with the
single-item-mutation helper, to save some repetition.
---
Hooks!
Here's a graph of all the hooks and how they depend on each other.
Consumers of feedback data (maybe new views, buttons, etc) should only
need to interface with either of the `useFetch*` hooks, and the
`useMutateFeedback` hook.
Hopefully `useFeedbackCache` will just work as we add new fields that
can be updated (like assigned to).
Also `useMutateFeedback` will need new tiny helpers to support things
like `assignTo`.
When we do "update all 100+ feedbacks" bulk operation, both these hooks
will probably need some changes again.
I setup the `FeedbackQueryKeys` context provider & hook. This guarantees
that queryKey objects are the exact same ref everywhere. So intead of
drilling the keys down through props, we can have the list-header, and
item header buttons all reference the same cached objects.
<img width="843" alt="SCR-20231031-jeum"
src="https://github.com/getsentry/sentry/assets/187460/16cfa993-b07b-4460-a15d-6a158e50f00d">
---
I also created some reusable code for mutations and put it inside
`queryClient.tsx` , `fetchMutation` is something that you can just pass
in like this, if you wanted, or wrap as i have (composition!):
```
const { ... } = useMutation({
mutationFn: fetchMutation,
});
```1 parent ba77ac1 commit 2fbc462
File tree
21 files changed
+453
-365
lines changed- static/app
- components/feedback
- feedbackItem
- list
- utils
- views/feedback
21 files changed
+453
-365
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
This file was deleted.
Lines changed: 27 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
| |||
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | | - | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | | - | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
29 | | - | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 37 | + | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
| 41 | + | |
43 | 42 | | |
44 | | - | |
45 | 43 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | 44 | | |
60 | 45 | | |
61 | 46 | | |
62 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
63 | 57 | | |
64 | 58 | | |
65 | 59 | | |
| |||
93 | 87 | | |
94 | 88 | | |
95 | 89 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
99 | 96 | | |
100 | 97 | | |
101 | 98 | | |
| |||
104 | 101 | | |
105 | 102 | | |
106 | 103 | | |
107 | | - | |
| 104 | + | |
| 105 | + | |
108 | 106 | | |
109 | 107 | | |
110 | 108 | | |
| |||
Lines changed: 5 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 10 | + | |
| 11 | + | |
20 | 12 | | |
21 | 13 | | |
22 | 14 | | |
| |||
29 | 21 | | |
30 | 22 | | |
31 | 23 | | |
32 | | - | |
| 24 | + | |
33 | 25 | | |
34 | 26 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 27 | + | |
41 | 28 | | |
42 | 29 | | |
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 32 | + | |
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | 36 | | |
39 | | - | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
44 | | - | |
45 | | - | |
| 41 | + | |
46 | 42 | | |
47 | 43 | | |
48 | 44 | | |
| |||
96 | 92 | | |
97 | 93 | | |
98 | 94 | | |
99 | | - | |
| 95 | + | |
100 | 96 | | |
101 | 97 | | |
102 | 98 | | |
| |||
Lines changed: 31 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
3 | 8 | | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
9 | | - | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
52 | | - | |
53 | | - | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
57 | 71 | | |
58 | 72 | | |
59 | 73 | | |
| |||
62 | 76 | | |
63 | 77 | | |
64 | 78 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
70 | 85 | | |
71 | 86 | | |
72 | 87 | | |
| |||
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
87 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
88 | 106 | | |
89 | 107 | | |
90 | 108 | | |
91 | 109 | | |
92 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
93 | 114 | | |
94 | 115 | | |
95 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
95 | 89 | | |
96 | 90 | | |
97 | 91 | | |
| |||
0 commit comments