Skip to content

Commit

Permalink
fix: fix channel.membership type (#1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
myandrienko authored May 16, 2024
1 parent 7e02ac8 commit 367cc20
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 75 deletions.
3 changes: 1 addition & 2 deletions src/channel_state.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Channel } from './channel';
import {
ChannelMemberResponse,
ChannelMembership,
FormatMessageResponse,
Event,
ExtendableGenerics,
Expand Down Expand Up @@ -42,7 +41,7 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
watchers: Record<string, UserResponse<StreamChatGenerics>>;
members: Record<string, ChannelMemberResponse<StreamChatGenerics>>;
unreadCount: number;
membership: ChannelMembership<StreamChatGenerics>;
membership: ChannelMemberResponse<StreamChatGenerics>;
last_message_at: Date | null;
/**
* Flag which indicates if channel state contain latest/recent messages or no.
Expand Down
28 changes: 12 additions & 16 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export type AppSettingsAPIResponse<StreamChatGenerics extends ExtendableGenerics
organization?: string;
permission_version?: string;
policies?: Record<string, Policy[]>;
poll_enabled?: boolean;
push_notifications?: {
offline_only: boolean;
version: string;
Expand Down Expand Up @@ -313,7 +314,7 @@ export type ChannelAPIResponse<StreamChatGenerics extends ExtendableGenerics = D
messages: MessageResponse<StreamChatGenerics>[];
pinned_messages: MessageResponse<StreamChatGenerics>[];
hidden?: boolean;
membership?: ChannelMembership<StreamChatGenerics> | null;
membership?: ChannelMemberResponse<StreamChatGenerics> | null;
pending_messages?: PendingMessageResponse<StreamChatGenerics>[];
read?: ReadResponse<StreamChatGenerics>[];
threads?: ThreadResponse[];
Expand All @@ -331,6 +332,7 @@ export type ChannelMemberAPIResponse<StreamChatGenerics extends ExtendableGeneri
};

export type ChannelMemberResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
ban_expires?: string;
banned?: boolean;
channel_role?: Role;
created_at?: string;
Expand Down Expand Up @@ -1667,9 +1669,9 @@ export type UserFilters<StreamChatGenerics extends ExtendableGenerics = DefaultG
| PrimitiveFilter<UserResponse<StreamChatGenerics>['name']>;
notifications_muted?:
| RequireOnlyOne<{
$eq?: PrimitiveFilter<UserResponse<StreamChatGenerics>['notifications_muted']>;
}>
| boolean;
$eq?: PrimitiveFilter<UserResponse<StreamChatGenerics>['notifications_muted']>;
}>
| boolean;
teams?:
| RequireOnlyOne<{
$contains?: PrimitiveFilter<string>;
Expand Down Expand Up @@ -2042,18 +2044,12 @@ export type ChannelData<
name?: string;
};

export type ChannelMembership<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
banned?: boolean;
channel_role?: Role;
created_at?: string;
is_moderator?: boolean;
notifications_muted?: boolean;
role?: string;
shadow_banned?: boolean;
status?: string;
updated_at?: string;
user?: UserResponse<StreamChatGenerics>;
};
/**
* @deprecated Use ChannelMemberResponse instead
*/
export type ChannelMembership<
StreamChatGenerics extends ExtendableGenerics = DefaultGenerics
> = ChannelMemberResponse<StreamChatGenerics>;

export type ChannelMute<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
user: UserResponse<StreamChatGenerics>;
Expand Down
Loading

0 comments on commit 367cc20

Please sign in to comment.