Skip to content

Commit

Permalink
feat: use marketplace-server trendings if FF enabled (#2338)
Browse files Browse the repository at this point in the history
* feat: use marketplace-server trendings if FF enabled

* fix: tests
  • Loading branch information
juanmahidalgo authored Dec 12, 2024
1 parent 9481cb7 commit ac14d7c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion webapp/src/modules/item/sagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ describe('when handling the fetch trending items request action', () => {
it('should dispatch a successful action with the fetched trending items', () => {
return expectSaga(itemSaga, getIdentity)
.provide([
[matchers.call.fn(waitForFeatureFlagsToBeLoaded), undefined],
[select(getIsMarketplaceServerEnabled), true],
[select(getIsOffchainPublicNFTOrdersEnabled), false],
[matchers.call.fn(ItemAPI.prototype.getTrendings), fetchResult],
Expand All @@ -691,7 +692,8 @@ describe('when handling the fetch trending items request action', () => {
it('should dispatch a successful action with the fetched trending items', () => {
return expectSaga(itemSaga, getIdentity)
.provide([
// [select(getIsMarketplaceServerEnabled), true],
[select(getIsMarketplaceServerEnabled), true],
[matchers.call.fn(waitForFeatureFlagsToBeLoaded), undefined],
[matchers.call.fn(ItemAPI.prototype.getTrendings), fetchResult],
[matchers.call.fn(waitForWalletConnectionAndIdentityIfConnecting), undefined]
])
Expand All @@ -706,6 +708,8 @@ describe('when handling the fetch trending items request action', () => {
it('should dispatch a failing action with the error and the options', () => {
return expectSaga(itemSaga, getIdentity)
.provide([
[select(getIsMarketplaceServerEnabled), true],
[matchers.call.fn(waitForFeatureFlagsToBeLoaded), undefined],
[matchers.call.fn(ItemAPI.prototype.getTrendings), Promise.reject(anError)],
[matchers.call.fn(waitForWalletConnectionAndIdentityIfConnecting), undefined]
])
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/modules/item/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,17 @@ export function* itemSaga(getIdentity: () => AuthIdentity | undefined) {
// If the wallet is getting connected, wait until it finishes to fetch the items so it can fetch them with authentication

try {
yield call(waitForFeatureFlagsToBeLoaded)
const isMarketplaceServerEnabled: boolean = yield select(getIsMarketplaceServerEnabled)
yield call(waitForWalletConnectionAndIdentityIfConnecting)
const { data }: { data: Item[] } = yield call([itemAPI, 'getTrendings'], size)
const { data }: { data: Item[] } = yield call([isMarketplaceServerEnabled ? marketplaceItemAPI : itemAPI, 'getTrendings'], size)

if (!data.length) {
yield put(fetchTrendingItemsSuccess([]))
return
}

const ids = data.map(item => item.id)
const isMarketplaceServerEnabled: boolean = yield select(getIsMarketplaceServerEnabled)
const api = isMarketplaceServerEnabled ? marketplaceServerCatalogAPI : catalogAPI
const isOffchainEnabled: boolean = yield select(getIsOffchainPublicNFTOrdersEnabled)
const { data: itemData }: { data: Item[]; total: number } = yield call(
Expand Down

0 comments on commit ac14d7c

Please sign in to comment.