Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix smart wearbale multiple issues #6080

Merged
merged 4 commits into from
Feb 8, 2024
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
11 changes: 10 additions & 1 deletion browser-interface/packages/shared/catalogs/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,17 @@ function fetchOwnedEmotes(ethAddress: string, client: CatalystClient) {
return client.fetchOwnedEmotes(ethAddress, true)
}

export function urnWithoutToken(urn: string): string {
const value = urn.split(':')
if (value.length === 7) {
return value.slice(0, 6).join(':')
}
return urn
}

async function fetchWearablesByFilters(filters: WearablesRequestFilters, client: CatalystClient) {
return client.fetchWearables(filters)
const wearableIds = filters.wearableIds?.map(urnWithoutToken)
return client.fetchWearables({ ...filters, wearableIds })
}

async function fetchEmotesByFilters(filters: EmotesRequestFilters, client: CatalystClient) {
Expand Down
11 changes: 10 additions & 1 deletion browser-interface/packages/shared/portableExperiences/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
REMOVE_SCENE_PX,
SHUTDOWN_ALL_PORTABLE_EXPERIENCES
} from './actions'
import { REMOVE_DESIRED_PORTABLE_EXPERIENCE, RemoveDesiredPortableExperienceAction } from '../wearablesPortableExperience/actions'

const INITIAL_STATE: PortableExperiencesState = {
deniedPortableExperiencesFromRenderer: [],
Expand All @@ -19,7 +20,7 @@ const INITIAL_STATE: PortableExperiencesState = {

export function portableExperienceReducer(
state?: PortableExperiencesState,
action?: PortableExperienceActions
action?: PortableExperienceActions | RemoveDesiredPortableExperienceAction
): PortableExperiencesState {
if (!state) {
return INITIAL_STATE
Expand All @@ -30,6 +31,14 @@ export function portableExperienceReducer(
}

switch (action.type) {
case REMOVE_DESIRED_PORTABLE_EXPERIENCE: {
return {
...state,
deniedPortableExperiencesFromRenderer: state.deniedPortableExperiencesFromRenderer.filter(
($) => $ !== action.payload.id
)
}
}
case SHUTDOWN_ALL_PORTABLE_EXPERIENCES: {
return { ...state, globalPortalExperienceShutDown: true }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from './actions'
import { waitForRealm } from 'shared/realm/waitForRealmAdapter'
import { KeyAndHash } from '../catalogs/types'
import { urnWithoutToken } from '../catalogs/sagas'

export function* wearablesPortableExperienceSaga(): any {
yield takeLatest(PROFILE_SUCCESS, handleSelfProfileSuccess)
Expand All @@ -29,13 +30,12 @@ export function* wearablesPortableExperienceSaga(): any {

function* handleSelfProfileSuccess(action: ProfileSuccessAction): any {
const isMyProfile: boolean = yield select(isCurrentUserId, action.payload.profile.userId)

// cancel the saga if we receive a profile from a different user
if (!isMyProfile) {
return
}

const newProfileWearables = action.payload.profile.avatar?.wearables || []
const newProfileWearables = action.payload.profile.avatar?.wearables.map(urnWithoutToken) || []
const currentDesiredPortableExperiences: Record<string, LoadableScene | null> = yield select(
getDesiredWearablePortableExpriences
)
Expand Down Expand Up @@ -69,9 +69,9 @@ function* handleProcessWearables(action: ProcessWearablesAction) {
const currentDesiredPortableExperiences: Record<string, LoadableScene | null> = yield select(
getDesiredWearablePortableExpriences
)

if (payload.wearable.id in currentDesiredPortableExperiences) {
yield put(addDesiredPortableExperience(payload.wearable.id, payload.wearable))
const wearableId = urnWithoutToken(payload.wearable.id)
if (wearableId in currentDesiredPortableExperiences) {
yield put(addDesiredPortableExperience(wearableId, payload.wearable))
}
}

Expand Down Expand Up @@ -150,7 +150,7 @@ export async function wearableToSceneEntity(wearable: WearableV2, defaultBaseUrl
const metadata: Scene = sceneJson ? await jsonFetch(baseUrl + sceneJson.hash) : defaultSceneJson()

return {
id: wearable.id,
id: urnWithoutToken(wearable.id),
baseUrl,
parentCid: 'avatar',
entity: {
Expand Down
2 changes: 0 additions & 2 deletions browser-interface/packages/shared/world/runtime-7/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export function createInternalEngine(id: string, parcels: string[], isGlobalScen

if (entityId >= AVATAR_RESERVED_ENTITIES.to) {
engine.removeEntity(entity)
console.error(`[BOEDO] Max amount of users reached`, entityId)
return
}
PlayerIdentityData.create(entity, { address: userId, isGuest: profile.isGuest })
Expand Down Expand Up @@ -115,7 +114,6 @@ export function createInternalEngine(id: string, parcels: string[], isGlobalScen
const entity = avatarMap.get(userId)

if (!entity) {
console.error(`[BOEDO] user not found !`, { userId })
return addUser(userId)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void DisableOrEnablePortableExperience(string pexId, bool isPlaying)

view.ShowEnabledToast(scene?.GetSceneName());
}
else
else if (scene != null)
{
portableExperiencesBridge.SetDisabledPortableExperiences(disabledPortableExperiences.GetKeys()
.Concat(new[] { pexId })
Expand Down