Skip to content

Commit

Permalink
Add WatchlistFacade to UserPresenceFacade
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenevides authored and MeenaAlfons committed Nov 14, 2022
1 parent 6597a3f commit 5c840f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/core/pusher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Options } from './options';
import { Config, getConfig } from './config';
import StrategyOptions from './strategies/strategy_options';
import UserFacade from './user';
import WatchlistFacade from './watchlist';


export default class Pusher {
/* STATIC PROPERTIES */
Expand Down Expand Up @@ -63,8 +63,7 @@ export default class Pusher {
connection: ConnectionManager;
timelineSenderTimer: PeriodicTimer;
user: UserFacade;
watchlist: WatchlistFacade;


constructor(app_key: string, options?: Options) {
checkAppKey(app_key);
options = options || {};
Expand Down Expand Up @@ -150,7 +149,6 @@ export default class Pusher {
this.timeline.info({ instances: Pusher.instances.length });

this.user = new UserFacade(this);
this.watchlist = new WatchlistFacade(this);

if (Pusher.isReady) {
this.connect();
Expand Down
5 changes: 5 additions & 0 deletions src/core/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
UserAuthenticationCallback
} from './auth/options';
import Channel from './channels/channel';
import WatchlistFacade from './watchlist';
import EventsDispatcher from './events/dispatcher';
import flatPromise from './utils/flat_promise';

Expand All @@ -14,6 +15,7 @@ export default class UserFacade extends EventsDispatcher {
user_data: any = null;
serverToUserChannel: Channel = null;
signinDonePromise: Promise<any> = null;
watchlist: WatchlistFacade;
private _signinDoneResolve: Function = null;

public constructor(pusher: Pusher) {
Expand All @@ -30,6 +32,9 @@ export default class UserFacade extends EventsDispatcher {
this._newSigninPromiseIfNeeded();
}
});

this.watchlist = new WatchlistFacade(pusher);

this.pusher.connection.bind('message', event => {
var eventName = event.event;
if (eventName === 'pusher:signin_success') {
Expand Down

0 comments on commit 5c840f5

Please sign in to comment.