@gitlab/duo-ui 8.7.7 → 8.7.8

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [8.7.8](https://gitlab.com/gitlab-org/duo-ui/compare/v8.7.7...v8.7.8) (2025-03-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * group threads by lastUpdatedAt in Chat history ([98d89dd](https://gitlab.com/gitlab-org/duo-ui/commit/98d89dd2bbb6e09d86468b383d9560265af99d95))
7
+
1
8
  ## [8.7.7](https://gitlab.com/gitlab-org/duo-ui/compare/v8.7.6...v8.7.7) (2025-03-26)
2
9
 
3
10
 
@@ -31,12 +31,14 @@ var script = {
31
31
  return date => formatLocalizedDate(date, this.preferredLocale);
32
32
  },
33
33
  groupedThreads() {
34
- return this.threads.reduce((threadsGroupedByDate, thread) => {
35
- const date = new Date(thread.createdAt);
36
- const dateKey = date.toISOString().split('T')[0];
34
+ if (!this.hasThreads) {
35
+ return {};
36
+ }
37
+ return this.threads.slice().sort((a, b) => this.compareThreadDates(b.lastUpdatedAt, a.lastUpdatedAt)).reduce((grouped, thread) => {
38
+ const dateKey = this.getDateKey(thread.lastUpdatedAt);
37
39
  return {
38
- ...threadsGroupedByDate,
39
- [dateKey]: [...(threadsGroupedByDate[dateKey] || []), thread]
40
+ ...grouped,
41
+ [dateKey]: [...(grouped[dateKey] || []), thread]
40
42
  };
41
43
  }, {});
42
44
  },
@@ -58,6 +60,12 @@ var script = {
58
60
  onClose() {
59
61
  this.$emit('close');
60
62
  },
63
+ compareThreadDates(dateA, dateB) {
64
+ return new Date(dateA) - new Date(dateB);
65
+ },
66
+ getDateKey(date) {
67
+ return new Date(date).toISOString().split('T')[0];
68
+ },
61
69
  sprintf
62
70
  },
63
71
  i18n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/duo-ui",
3
- "version": "8.7.7",
3
+ "version": "8.7.8",
4
4
  "description": "Duo UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -39,15 +39,20 @@ export default {
39
39
  },
40
40
 
41
41
  groupedThreads() {
42
- return this.threads.reduce((threadsGroupedByDate, thread) => {
43
- const date = new Date(thread.createdAt);
44
- const dateKey = date.toISOString().split('T')[0];
45
-
46
- return {
47
- ...threadsGroupedByDate,
48
- [dateKey]: [...(threadsGroupedByDate[dateKey] || []), thread],
49
- };
50
- }, {});
42
+ if (!this.hasThreads) {
43
+ return {};
44
+ }
45
+
46
+ return this.threads
47
+ .slice()
48
+ .sort((a, b) => this.compareThreadDates(b.lastUpdatedAt, a.lastUpdatedAt))
49
+ .reduce((grouped, thread) => {
50
+ const dateKey = this.getDateKey(thread.lastUpdatedAt);
51
+ return {
52
+ ...grouped,
53
+ [dateKey]: [...(grouped[dateKey] || []), thread],
54
+ };
55
+ }, {});
51
56
  },
52
57
 
53
58
  hasThreads() {
@@ -73,6 +78,14 @@ export default {
73
78
  this.$emit('close');
74
79
  },
75
80
 
81
+ compareThreadDates(dateA, dateB) {
82
+ return new Date(dateA) - new Date(dateB);
83
+ },
84
+
85
+ getDateKey(date) {
86
+ return new Date(date).toISOString().split('T')[0];
87
+ },
88
+
76
89
  sprintf,
77
90
  },
78
91
  i18n,