Skip to content

Commit

Permalink
fix(combine-adapters): to not be stuck in configuring state (#1798)
Browse files Browse the repository at this point in the history
* fix(combine-adapters): to not be stuck in configuring state

* Create ninety-nails-teach.md
  • Loading branch information
tdeekens authored Aug 20, 2023
1 parent 7f20bd7 commit f5b9d93
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-nails-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@flopflip/combine-adapters": patch
---

fix(combine-adapters): to not be stuck in configuring state
4 changes: 2 additions & 2 deletions packages/combine-adapters/src/adapter/adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@ describe('when combining', () => {
);
});

it('should indicate that the adapter is not configured', () => {
it('should indicate that the adapter is configured regardless', () => {
expect(
adapter.getIsConfigurationStatus(AdapterConfigurationStatus.Configured)
).toBe(false);
).toBe(true);
});
});

Expand Down
12 changes: 12 additions & 0 deletions packages/combine-adapters/src/adapter/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,22 @@ class CombineAdapters implements TCombinedAdapterInterface {
initializationStatus === AdapterInitializationStatus.Succeeded
);

// NOTE: We consider this adapter reconfigured if all adapters have been asked to do so
// and have reported to be initialized successfully.
this.setConfigurationStatus(AdapterConfigurationStatus.Configured);

this.#adapterState.emitter.emit(this.#__internalConfiguredStatusChange__);

if (haveAllAdaptersInitializedSuccessfully) {
return { initializationStatus: AdapterInitializationStatus.Succeeded };
}

// NOTE: If not all adapters have initialized successfully we can not consider
// this adapter being configured fully.
this.setConfigurationStatus(AdapterConfigurationStatus.Unconfigured);

this.#adapterState.emitter.emit(this.#__internalConfiguredStatusChange__);

return { initializationStatus: AdapterInitializationStatus.Failed };
});
}
Expand Down

0 comments on commit f5b9d93

Please sign in to comment.