Skip to content
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

fix some types #437

Merged
merged 2 commits into from
Mar 19, 2021
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
10 changes: 5 additions & 5 deletions src/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export type RankedFeedOptions = {
session?: string;
};

export type GetFeedOptions = FeedPaginationOptions & EnrichOptions & RankedFeedOptions;

export type NotificationFeedOptions = {
mark_read?: boolean | 'current' | string[];
mark_seen?: boolean | 'current' | string[];
};

export type GetFeedOptions = FeedPaginationOptions & EnrichOptions & RankedFeedOptions & NotificationFeedOptions;

export type GetFollowOptions = {
filter?: string[];
limit?: number;
Expand Down Expand Up @@ -476,12 +476,12 @@ export class StreamFeed<
* @link https://getstream.io/activity-feeds/docs/node/adding_activities/?language=js#retrieving-activities
* @method get
* @memberof StreamFeed.prototype
* @param {GetFeedOptions & NotificationFeedOptions} options Additional options
* @param {GetFeedOptions} options Additional options
* @return {Promise<FeedAPIResponse>}
* @example feed.get({limit: 10, id_lte: 'activity-id'})
* @example feed.get({limit: 10, mark_seen: true})
*/
get(options: GetFeedOptions & NotificationFeedOptions = {}) {
get(options: GetFeedOptions = {}) {
const extraOptions: { mark_read?: boolean | string; mark_seen?: boolean | string } = {};

if (options.mark_read && (options.mark_read as string[]).join) {
Expand Down Expand Up @@ -548,7 +548,7 @@ export class StreamFeed<
* console.log('we are now listening to changes');
* });
*/
subscribe(callback: Faye.Callback<RealTimeMessage<UserType, ActivityType>>) {
subscribe(callback: Faye.SubscribeCallback<RealTimeMessage<UserType, ActivityType>>) {
if (!this.client.appId) {
throw new SiteError(
'Missing app id, which is needed to subscribe, use var client = stream.connect(key, secret, appId);',
Expand Down
6 changes: 3 additions & 3 deletions src/reaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class StreamReaction<
add(
kind: string,
activity: string | { id: string },
data: ReactionType,
data?: ReactionType,
{ id, targetFeeds = [], userId, targetFeedsExtraData }: ReactionAddOptions = {},
) {
const body: ReactionBody<ReactionType> = {
Expand Down Expand Up @@ -188,7 +188,7 @@ export class StreamReaction<
addChild(
kind: string,
reaction: string | { id: string },
data: ChildReactionType,
data?: ChildReactionType,
{ targetFeeds = [], userId, targetFeedsExtraData }: ReactionAddChildOptions = {},
) {
const body: ReactionBody<ChildReactionType> = {
Expand Down Expand Up @@ -279,7 +279,7 @@ export class StreamReaction<
*/
update(
id: string,
data: ReactionType | ChildReactionType,
data?: ReactionType | ChildReactionType,
{ targetFeeds = [], targetFeedsExtraData }: ReactionUpdateOptions = {},
) {
const body: ReactionBody<ReactionType | ChildReactionType> = {
Expand Down
4 changes: 2 additions & 2 deletions types/modules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare module 'faye' {
};

type Callback<T extends UR = UR> = (message: Message<T>) => unknown;
type SubscribeCallback<T extends UR = UR> = (data: T) => unknown;

type Middleware<T extends UR = UR> = {
incoming: (message: Message<T>, callback: Callback<T>) => unknown;
Expand All @@ -23,8 +24,7 @@ declare module 'faye' {
export class Client<T extends UR = UR> {
constructor(url: string, options: { timeout: number });
addExtension(extension: Middleware<T>): void;
subscribe(channel: string, callback: Callback<T>): Promise<Subscription>;

subscribe(channel: string, callback: SubscribeCallback<T>): Promise<Subscription>;
disconnect(): void;
}
}