Skip to content

Commit

Permalink
feat: reaction details are now paginated
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Sep 16, 2024
1 parent 1e7b3bf commit 9829e31
Show file tree
Hide file tree
Showing 41 changed files with 980 additions and 377 deletions.
27 changes: 27 additions & 0 deletions docusaurus/docs/Angular/components/PaginatedListComponent.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
The `PaginatedListComponent` can display a list of arbitrary data with support for loading indicator and pagination. This is a utility component, you don't need to use it unless you're building a custom component.

## Usage

The paginated list component relies on data provided by the parent component. You can provide the HTML template for the list items.

```html
<stream-paginated-list
[items]="<list of items to display>"
[isLoading]="<set to true to display loading indicator>"
[hasMore]="<whether or not the list has more pages to retrieve>"
(loadMore)="<use this output to fetch the next page of items>"
>
<ng-template let-item="item" let-index="index"
><div data-testid="test-item" [style.height]="height">
{{ index }}. {{ item }}
</div></ng-template
>
</stream-user-list>
```

## Customization

You can provide the HTML template for the list items, see above example.

[//]: # "Start of generated content"
[//]: # "End of generated content"
21 changes: 21 additions & 0 deletions docusaurus/docs/Angular/components/UserListComponent.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The `UserListComponent` can display a list of Stream users with pagination. This can be useful if you want to build a user list in your application.

## Usage

The user list component relies on data provided by the parent component:

```html
<stream-user-list
[users]="<list of users to display>"
[isLoading]="<set to true to display loading indicator>"
[hasMore]="<whether or not the list has more pages to retrieve>"
(loadMore)="<use this output to fetch the next page of users>"
></stream-user-list>
```

## Customization

The component is built on top of the [`PaginatedListComponent`](../../components/PaginatedListComponent.mdx), you can use that component to build your own user list component.

[//]: # "Start of generated content"
[//]: # "End of generated content"
61 changes: 45 additions & 16 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
"ngx-float-ui": "^15.0.0",
"pretty-bytes": "^6.1.1",
"rxjs": "~7.4.0",
"stream-chat": "^8.26.0",
"starwars-names": "^1.6.0",
"stream-chat": "^8.40.1",
"ts-node": "^10.9.2",
"tslib": "^2.3.0",
"uuid": "^9.0.1",
Expand All @@ -141,10 +141,10 @@
"@semantic-release/exec": "^6.0.2",
"@semantic-release/git": "^10.0.1",
"@types/jasmine": "~3.8.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@types/starwars-names": "^1.6.2",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"copyfiles": "^2.4.1",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.3.0",
Expand All @@ -161,7 +161,7 @@
"karma-jasmine-html-reporter": "~1.7.0",
"lint-staged": "^11.1.2",
"ng-packagr": "^15.2.2",
"prettier": "^2.4.0",
"prettier": "^2.8.8",
"prettier-eslint": "^13.0.0",
"semantic-release": "^18.0.0",
"typedoc": "^0.25.13",
Expand Down
6 changes: 2 additions & 4 deletions projects/customizations-example/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,12 @@

<ng-template
#messageReactionsTemplate
let-messageReactionCounts="messageReactionCounts"
let-latestReactions="latestReactions"
let-messageReactionGroups="messageReactionGroups"
let-messageId="messageId"
let-ownReactions="ownReactions"
>
<stream-message-reactions
[messageReactionCounts]="messageReactionCounts"
[latestReactions]="latestReactions"
[messageReactionGroups]="messageReactionGroups"
[messageId]="messageId"
[ownReactions]="ownReactions"
></stream-message-reactions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<div class="message">{{ message?.text }}</div>
<div class="sender-info">
{{ message?.user?.name || message?.user?.id }} |
{{ message?.created_at | date: "long" }}
{{ message?.created_at | date : "long" }}
</div>
</div>
3 changes: 2 additions & 1 deletion projects/stream-chat-angular/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"rules": {
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off"
"@typescript-eslint/no-unsafe-member-access": "off",
"@angular-eslint/component-max-inline-declarations": "off"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,7 @@
></ng-container>
<ng-template #defaultFile let-attachmentContext="attachment">
<div
class="
str-chat__message-attachment-file--item
str-chat-angular__message-attachment-file-single
"
class="str-chat__message-attachment-file--item str-chat-angular__message-attachment-file-single"
>
<stream-icon-placeholder
class="str-chat__attachment-type-icon"
Expand Down Expand Up @@ -447,10 +444,7 @@
<div class="stream-chat-angular__image-modal str-chat__image-carousel">
<img
#imgElement
class="
stream-chat-angular__image-modal-image
str-chat__image-carousel-image
"
class="stream-chat-angular__image-modal-image str-chat__image-carousel-image"
data-testid="modal-image"
[src]="
getCarouselImageAttachmentConfiguration(
Expand Down Expand Up @@ -484,10 +478,7 @@
/>
<div>
<button
class="
stream-chat-angular__image-modal-stepper
str-chat__image-carousel-stepper str-chat__image-carousel-stepper-prev
"
class="stream-chat-angular__image-modal-stepper str-chat__image-carousel-stepper str-chat__image-carousel-stepper-prev"
data-testid="image-modal-prev"
type="button"
[ngStyle]="{
Expand All @@ -499,10 +490,7 @@
<stream-icon-placeholder icon="arrow-left"></stream-icon-placeholder>
</button>
<button
class="
stream-chat-angular__image-modal-stepper
str-chat__image-carousel-stepper str-chat__image-carousel-stepper-next
"
class="stream-chat-angular__image-modal-stepper str-chat__image-carousel-stepper str-chat__image-carousel-stepper-next"
type="button"
data-testid="image-modal-next"
[ngStyle]="{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
<div class="str-chat__header-livestream-left str-chat__channel-header-end">
<p
data-testid="name"
class="
str-chat__header-livestream-left--title str-chat__channel-header-title
"
class="str-chat__header-livestream-left--title str-chat__channel-header-title"
>
{{ displayText }}
</p>
Expand All @@ -25,10 +23,7 @@
<ng-template #defaultChannelInfo>
<p
data-testid="info"
class="
str-chat__header-livestream-left--members
str-chat__channel-header-info
"
class="str-chat__header-livestream-left--members str-chat__channel-header-info"
>
{{'streamChat.{{ memberCount }} members' | translate:memberCountParam}}
{{canReceiveConnectEvents ? ('streamChat.{{ watcherCount }} online' |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@
>
<div class="str-chat__loading-channels-avatar"></div>
<div
class="
str-chat__loading-channels-meta str-chat__channel-preview-end-loading
"
class="str-chat__loading-channels-meta str-chat__channel-preview-end-loading"
>
<div class="str-chat__loading-channels-username"></div>
<div class="str-chat__loading-channels-status"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
></stream-avatar-placeholder>
</div>
<div
class="
str-chat__channel-preview-messenger--right str-chat__channel-preview-end
"
class="str-chat__channel-preview-messenger--right str-chat__channel-preview-end"
>
<ng-container
*ngTemplateOutlet="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe('ChannelPreviewComponent', () => {
component.channel = channel;
fixture.detectChanges();
const deletedMessage = mockMessage();
deletedMessage.deleted_at = new Date().toISOString();
deletedMessage.deleted_at = new Date();
channel.state.latestMessages[channel.state.latestMessages.length - 1] =
deletedMessage;
channel.handleEvent('message.updated', { message: deletedMessage });
Expand Down
10 changes: 8 additions & 2 deletions projects/stream-chat-angular/src/lib/channel.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ describe('ChannelService', () => {
service.activeChannel$.subscribe((c) => (activeChannel = c!));
const message =
activeChannel.state.messages[activeChannel.state.messages.length - 1];
message.deleted_at = new Date().toISOString();
message.deleted_at = new Date();
(activeChannel as MockChannel).handleEvent('message.deleted', { message });

expect(spy).toHaveBeenCalledWith(jasmine.arrayContaining([message]));
Expand Down Expand Up @@ -2153,7 +2153,13 @@ describe('ChannelService', () => {
expect(mockChatClient.queryChannels).toHaveBeenCalledWith(
jasmine.any(Object),
jasmine.any(Object),
{ limit: 20, state: true, presence: true, watch: true, message_limit: 25 }
{
limit: 20,
state: true,
presence: true,
watch: true,
message_limit: 25,
}
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ describe('ChannelService - threads', () => {
messages: [messageToDelete],
} as any as GetRepliesAPIResponse<DefaultStreamChatGenerics>);
await service.setAsActiveParentMessage(parentMessage);
messageToDelete.deleted_at = new Date().toISOString();
messageToDelete.deleted_at = new Date();
activeChannel.state.threads = { [parentMessage.id]: [messageToDelete] };
(activeChannel as MockChannel).handleEvent('message.deleted', {
message: messageToDelete,
Expand Down
Loading

0 comments on commit 9829e31

Please sign in to comment.