feat: Extend the connect to worl component to allow receiving the url form query params
This commit is contained in:
parent
afe5a31fa9
commit
08b3e79581
@ -1,20 +1,22 @@
|
||||
import { connect } from 'react-redux'
|
||||
import { getAddress, isConnecting } from 'decentraland-dapps/dist/modules/wallet/selectors'
|
||||
import { setServer, setToken } from '../../../modules/conference/action'
|
||||
import { config } from '../../../modules/config'
|
||||
import { getCurrentIdentity, isLoggingIn } from '../../../modules/identity/selector'
|
||||
import { RootState } from '../../../modules/reducer'
|
||||
import withRouter from '../../../utils/WithRouter'
|
||||
import { getPreviouslyLoadedServers } from '../../../utils/worldServers'
|
||||
import MainPage from './ConnectToWorld'
|
||||
import { MapDispatch, MapDispatchProps, MapStateProps } from './ConnectToWorld.types'
|
||||
import { MapDispatch, MapDispatchProps, MapStateProps, OwnProps } from './ConnectToWorld.types'
|
||||
|
||||
const mapStateToProps = (state: RootState): MapStateProps => {
|
||||
const mapStateToProps = (state: RootState, ownProps: OwnProps): MapStateProps => {
|
||||
const identity = getCurrentIdentity(state)
|
||||
|
||||
return {
|
||||
isLoading: isLoggingIn(state) || isConnecting(state),
|
||||
loggedInAddress: getAddress(state)?.toLowerCase(),
|
||||
previouslyLoadedServers: getPreviouslyLoadedServers(),
|
||||
worldsContentServerUrl:
|
||||
new URLSearchParams(ownProps.router.location.search).get('worlds-content-server-url') || config.get('WORLDS_CONTENT_SERVER_URL'),
|
||||
identity
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ function ConnectToWorld(props: Props) {
|
||||
const [availableServers, setAvailableServers] = useState<string[]>([])
|
||||
const [isConnectingToServer] = useState(false)
|
||||
|
||||
const { isLoading, loggedInAddress, identity, previouslyLoadedServers, onSubmitConnectForm } = props
|
||||
const { isLoading, loggedInAddress, identity, previouslyLoadedServers, worldsContentServerUrl, onSubmitConnectForm } = props
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
@ -100,11 +100,7 @@ function ConnectToWorld(props: Props) {
|
||||
try {
|
||||
if (!identity) return
|
||||
|
||||
const response: { url: string; token: string } = await livekitConnect(
|
||||
identity,
|
||||
'https://worlds-content-server.decentraland.zone',
|
||||
selectedServer
|
||||
)
|
||||
const response: { url: string; token: string } = await livekitConnect(identity, worldsContentServerUrl, selectedServer)
|
||||
onSubmitConnectForm(response.url, response.token)
|
||||
addServerToPreviouslyLoaded(selectedServer)
|
||||
navigate(`/meet/${encodeURIComponent(response.url)}?token=${encodeURIComponent(response.token)}`)
|
||||
|
||||
@ -7,17 +7,15 @@ export type Props = {
|
||||
isLoading: boolean
|
||||
previouslyLoadedServers: string[] | null
|
||||
identity: AuthIdentity | null
|
||||
worldsContentServerUrl: string
|
||||
onSubmitConnectForm: (server: string, token: string) => void
|
||||
}
|
||||
|
||||
export type MapStateProps = Pick<Props, 'loggedInAddress' | 'isLoading' | 'previouslyLoadedServers' | 'identity'>
|
||||
export type MapStateProps = Pick<Props, 'loggedInAddress' | 'isLoading' | 'previouslyLoadedServers' | 'identity' | 'worldsContentServerUrl'>
|
||||
export type MapDispatchProps = Pick<Props, 'onSubmitConnectForm'>
|
||||
export type MapDispatch = Dispatch
|
||||
|
||||
// TODO: world-content-server qs
|
||||
type Params = {
|
||||
profileAddress?: string
|
||||
}
|
||||
type Params = Record<string, never>
|
||||
export type OwnProps = {
|
||||
router: RouterProps<Params>
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user