Skip to content

Commit

Permalink
fix: don’t double call onHero
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Nov 17, 2022
1 parent 33a654c commit 3ae1326
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/lib/Hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default class Hero extends AwaitedEventTarget<{
readonly #clientPlugins: IClientPlugin[] = [];
readonly #connectionToCore: ConnectionToHeroCore;
readonly #didAutoCreateConnection: boolean = false;
#didInitializeClientPlugins = false;
#coreSessionPromise: Promise<CoreSession | Error>;
#tabs: Tab[];
#activeTab: Tab;
Expand Down Expand Up @@ -418,7 +419,7 @@ export default class Hero extends AwaitedEventTarget<{
clientPlugins.push(clientPlugin);
this.#options.dependencyMap[ClientPlugin.id] = ClientPlugin.coreDependencyIds || [];
}
if (this.#coreSessionPromise) {
if (this.#didInitializeClientPlugins) {
this.#initializeClientPlugins(clientPlugins);
}
}
Expand Down Expand Up @@ -614,6 +615,7 @@ export default class Hero extends AwaitedEventTarget<{
}

#initializeClientPlugins(plugins: IClientPlugin[]): void {
this.#didInitializeClientPlugins = true;
for (const clientPlugin of plugins) {
if (clientPlugin.onHero) clientPlugin.onHero(this, this.#sendToActiveTab.bind(this));
}
Expand Down

0 comments on commit 3ae1326

Please sign in to comment.