Skip to content

Reactive channel list #691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"pretty-bytes": "^6.1.1",
"rxjs": "~7.4.0",
"starwars-names": "^1.6.0",
"stream-chat": "^8.44.0",
"stream-chat": "^8.57.2",
"ts-node": "^10.9.2",
"tslib": "^2.3.0",
"uuid": "^11.1.0",
Expand Down
9 changes: 4 additions & 5 deletions projects/sample-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ export class AppComponent implements AfterViewInit {
: environment.userToken,
{ timeout: 10000 },
);
void this.channelService.init(
environment.channelsFilter || {
void this.channelService.init({
filters: environment.channelsFilter || {
type: 'messaging',
members: { $in: [environment.userId] },
},
undefined,
{ limit: 10 },
);
options: { limit: 10 },
});
this.streamI18nService.setTranslation();
this.channelService.activeParentMessage$
.pipe(map((m) => !!m))
Expand Down
3 changes: 2 additions & 1 deletion projects/stream-chat-angular/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = function (config) {
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
random: false,
},
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
Expand All @@ -27,7 +28,7 @@ module.exports = function (config) {
coverageReporter: {
dir: require("path").join(
__dirname,
"../../coverage/stream-chat-angular"
"../../coverage/stream-chat-angular",
),
subdir: ".",
reporters: [{ type: "html" }, { type: "text-summary" }],
Expand Down
2 changes: 1 addition & 1 deletion projects/stream-chat-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@breezystack/lamejs": "^1.2.7",
"@ngx-translate/core": "^16.0.0",
"rxjs": "^7.4.0",
"stream-chat": "^8.44.0"
"stream-chat": "^8.57.2"
},
"peerDependenciesMeta": {
"@breezystack/lamejs": {
Expand Down
1 change: 1 addition & 0 deletions projects/stream-chat-angular/src/assets/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@ export const en = {
'You currently have {{count}} attachments, the maximum is {{max}}':
'You currently have {{count}} attachments, the maximum is {{max}}',
'and others': 'and others',
'Reload channels': 'Reload channels',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@
</div>
} @else {
@if (isError$ | async) {
<div data-testid="chatdown-container" class="str-chat__down">
<ng-container *ngTemplateOutlet="loadingChannels" />
<div
data-testid="chatdown-container"
class="str-chat__dow str-chat__channel-list-empty"
>
<button (click)="recoverState()" class="str-chat__cta-button">
{{ "streamChat.Reload channels" | translate }}
</button>
</div>
}
@if (isInitializing$ | async) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ describe('ChannelListComponent', () => {
it('should display error indicator, if error happened', () => {
expect(queryChatdownContainer()).toBeNull();

channelServiceMock.channelQueryState$.next({
state: 'error',
error: new Error('error'),
});
channelServiceMock.shouldRecoverState$.next(true);
fixture.detectChanges();

expect(queryChatdownContainer()).not.toBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export class ChannelListComponent implements OnDestroy {
this.theme$ = this.themeService.theme$;
this.channels$ = this.channelService.channels$;
this.hasMoreChannels$ = this.channelService.hasMoreChannels$;
this.isError$ = this.channelService.channelQueryState$.pipe(
map((s) => !this.isLoadingMoreChannels && s?.state === 'error'),
);
this.isError$ = this.channelService.shouldRecoverState$;
this.isInitializing$ = this.channelService.channelQueryState$.pipe(
map((s) => !this.isLoadingMoreChannels && s?.state === 'in-progress'),
);
Expand All @@ -56,6 +54,10 @@ export class ChannelListComponent implements OnDestroy {
this.isLoadingMoreChannels = false;
}

recoverState() {
void this.channelService.recoverState();
}

trackByChannelId(_: number, item: Channel<DefaultStreamChatGenerics>) {
return item.cid;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, NgZone, OnDestroy, OnInit } from '@angular/core';
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { filter } from 'rxjs/operators';
import { Channel, Event, FormatMessageResponse } from 'stream-chat';
Expand Down Expand Up @@ -41,7 +41,6 @@ export class ChannelPreviewComponent implements OnInit, OnDestroy {

constructor(
private channelService: ChannelService,
private ngZone: NgZone,
private chatClientService: ChatClientService,
messageService: MessageService,
public customTemplatesService: CustomTemplatesService,
Expand Down
2 changes: 0 additions & 2 deletions projects/stream-chat-angular/src/lib/channel-query.spec.ts

This file was deleted.

115 changes: 0 additions & 115 deletions projects/stream-chat-angular/src/lib/channel-query.ts

This file was deleted.

Loading
Loading