Skip to content
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
3 changes: 2 additions & 1 deletion packages/feeds-client/src/feed/event-handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from './feed-member';
export * from './bookmark';
export * from './activity';
export * from './feed';
export * from './notification-feed';
export * from './notification-feed';
export * from './watch';
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Feed } from '../../feed';

export function handleWatchStarted(this: Feed) {
this.state.partialNext({ watch: true });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Feed } from '../../feed';

export function handleWatchStopped(this: Feed) {
this.state.partialNext({ watch: false });
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './handle-watch-started';
export * from './handle-watch-stopped';
18 changes: 0 additions & 18 deletions packages/feeds-client/src/feed/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,24 +316,6 @@ export class Feed extends FeedApi {
}
}

/**
* @internal
*/
handleWatchStopped() {
this.state.partialNext({
watch: false,
});
}

/**
* @internal
*/
handleWatchStarted() {
this.state.partialNext({
watch: true,
});
}

/**
* Returns index of the provided comment object.
*/
Expand Down
8 changes: 5 additions & 3 deletions packages/feeds-client/src/feeds-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import {
handleFollowCreated,
handleFollowDeleted,
handleFollowUpdated,
handleWatchStarted,
handleWatchStopped,
} from './feed';

export type FeedsClientState = {
Expand Down Expand Up @@ -107,7 +109,7 @@ export class FeedsClient extends FeedsApi {
}
} else {
for (const activeFeed of Object.values(this.activeFeeds)) {
activeFeed.handleWatchStopped();
handleWatchStopped.bind(activeFeed)();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we always need to bind these now, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do fn.call(instance) instead too.

}
}
break;
Expand Down Expand Up @@ -436,7 +438,7 @@ export class FeedsClient extends FeedsApi {
const feed =
this.activeFeeds[`${request.feed_group_id}:${request.feed_id}`];
if (feed) {
feed.handleWatchStopped();
handleWatchStopped.bind(feed)();
}

return response;
Expand All @@ -452,7 +454,7 @@ export class FeedsClient extends FeedsApi {
if (this.activeFeeds[fid]) {
const feed = this.activeFeeds[fid];
if (watch && !feed.currentState.watch) {
feed.handleWatchStarted();
handleWatchStarted.bind(feed)();
}
return feed;
} else {
Expand Down