Skip to content

Commit aa1cebd

Browse files
google-genai-botcopybara-github
authored andcommitted
ADK changes
PiperOrigin-RevId: 832200562
1 parent e9ca45b commit aa1cebd

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

src/app/components/session-tab/session-tab.component.spec.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ describe('SessionTabComponent', () => {
126126
.toBeTruthy();
127127
});
128128

129-
it('should hide session list', fakeAsync(() => {
130-
expect(fixture.debugElement.query(
131-
CSS_SELECTORS.SESSION_LIST))
132-
.toBeFalsy();
133-
}));
129+
it(
130+
'should hide session list', fakeAsync(() => {
131+
expect(fixture.debugElement.query(CSS_SELECTORS.SESSION_LIST))
132+
.toBeFalsy();
133+
}));
134134
});
135135

136136
it('should call listSessions with filter', fakeAsync(() => {
@@ -149,19 +149,17 @@ describe('SessionTabComponent', () => {
149149
beforeEach(fakeAsync(() => {
150150
mockUiStateService.isSessionListLoadingResponse.next(false);
151151
sessionService.listSessionsResponse.next({
152-
items: [
153-
{id: 'session2', lastUpdateTime: 2}
154-
],
152+
items: [{id: 'session2', lastUpdateTime: 2}],
155153
nextPageToken: '',
156154
});
157155
fixture.detectChanges();
158156
}));
159157

160-
it('should show session list', fakeAsync(() => {
161-
expect(fixture.debugElement.query(
162-
CSS_SELECTORS.SESSION_LIST))
163-
.toBeTruthy();
164-
}));
158+
it(
159+
'should show session list', fakeAsync(() => {
160+
expect(fixture.debugElement.query(CSS_SELECTORS.SESSION_LIST))
161+
.toBeTruthy();
162+
}));
165163

166164
it(
167165
'should show the filtered list items only', fakeAsync(() => {
@@ -179,7 +177,11 @@ describe('SessionTabComponent', () => {
179177
describe('when "Load more" is clicked', () => {
180178
beforeEach(fakeAsync(() => {
181179
sessionService.listSessionsResponse.next({
182-
items: [{id: 'session1', lastUpdateTime: 1}],
180+
items: [
181+
{id: 'session1', lastUpdateTime: 1},
182+
{id: 'session1', lastUpdateTime: 1},
183+
{id: 'session3', lastUpdateTime: 1}
184+
],
183185
nextPageToken: 'nextPage',
184186
});
185187
fixture = TestBed.createComponent(SessionTabComponent);
@@ -229,11 +231,11 @@ describe('SessionTabComponent', () => {
229231
.toBeFalsy();
230232
}));
231233

232-
it('should show session list', fakeAsync(() => {
233-
expect(fixture.debugElement.query(
234-
CSS_SELECTORS.SESSION_LIST))
235-
.toBeTruthy();
236-
}));
234+
it(
235+
'should show session list', fakeAsync(() => {
236+
expect(fixture.debugElement.query(CSS_SELECTORS.SESSION_LIST))
237+
.toBeTruthy();
238+
}));
237239
it('should extend list with new sessions', () => {
238240
expect(fixture.debugElement.query(CSS_SELECTORS.SESSION_LIST)
239241
.children.length)

src/app/components/session-tab/session-tab.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,16 @@ export class SessionTabComponent implements OnInit {
112112
.pipe(catchError(() => of({items: [], nextPageToken: ''})));
113113
}),
114114
tap(({items, nextPageToken}) => {
115-
this.sessionList = [...this.sessionList, ...items].sort(
116-
(a: any, b: any) =>
117-
Number(b.lastUpdateTime) - Number(a.lastUpdateTime),
115+
this.sessionList = Array.from(
116+
new Map(
117+
[...this.sessionList, ...items].map((session) => [
118+
session.id,
119+
session,
120+
]),
121+
).values(),
122+
).sort(
123+
(a: any, b: any) =>
124+
Number(b.lastUpdateTime) - Number(a.lastUpdateTime),
118125
);
119126
this.pageToken = nextPageToken ?? '';
120127
this.canLoadMoreSessions = !!nextPageToken;

0 commit comments

Comments
 (0)