Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

refactor(client-core)(instance-server-settings service): remove action receptor usage #8354

Merged
merged 2 commits into from
Jul 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ Ethereal Engine. All Rights Reserved.

import { Paginated } from '@feathersjs/feathers'

import { matches, Validator } from '@etherealengine/engine/src/common/functions/MatchesUtils'
import { Engine } from '@etherealengine/engine/src/ecs/classes/Engine'
import {
instanceServerSettingPath,
InstanceServerSettingType
} from '@etherealengine/engine/src/schemas/setting/instance-server-setting.schema'
import { defineAction, defineState, dispatchAction, getMutableState } from '@etherealengine/hyperflux'
import { defineState, getMutableState } from '@etherealengine/hyperflux'

import { NotificationService } from '../../../common/services/NotificationService'

Expand All @@ -43,33 +42,18 @@ export const AdminInstanceServerSettingsState = defineState({
})
})

const fetchedInstanceServerReceptor = (
action: typeof InstanceServerSettingActions.fetchedInstanceServer.matches._TYPE
) => {
const state = getMutableState(AdminInstanceServerSettingsState)
return state.merge({ instanceServer: action.instanceServerSettings.data, updateNeeded: false })
}

export const AdminInstanceServerReceptors = {
fetchedInstanceServerReceptor
}

export const InstanceServerSettingService = {
fetchedInstanceServerSettings: async (inDec?: 'increment' | 'decrement') => {
try {
const instanceServerSettings = (await Engine.instance.api
.service(instanceServerSettingPath)
.find()) as Paginated<InstanceServerSettingType>
dispatchAction(InstanceServerSettingActions.fetchedInstanceServer({ instanceServerSettings }))
getMutableState(AdminInstanceServerSettingsState).merge({
instanceServer: instanceServerSettings.data,
updateNeeded: false
})
} catch (err) {
NotificationService.dispatchNotify(err.message, { variant: 'error' })
}
}
}

export class InstanceServerSettingActions {
static fetchedInstanceServer = defineAction({
type: 'ee.client.InstanceServerSetting.INSTANCE_SERVER_SETTING_DISPLAY',
instanceServerSettings: matches.object as Validator<unknown, Paginated<InstanceServerSettingType>>
})
}
14 changes: 0 additions & 14 deletions packages/client-core/src/systems/AdminSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ import {
import { AdminCoilSettingActions, CoilSettingReceptors } from '../admin/services/Setting/CoilSettingService'
import { EmailSettingActions, EmailSettingReceptors } from '../admin/services/Setting/EmailSettingService'
import { AdminHelmSettingActions, HelmSettingReceptors } from '../admin/services/Setting/HelmSettingService'
import {
AdminInstanceServerReceptors,
InstanceServerSettingActions
} from '../admin/services/Setting/InstanceServerSettingService'

const fetchedCoilQueue = defineActionQueue(AdminCoilSettingActions.fetchedCoil.matches)
const fetchedEmailQueue = defineActionQueue(EmailSettingActions.fetchedEmail.matches)
Expand All @@ -47,12 +43,7 @@ const patchedHelmQueue = defineActionQueue(AdminHelmSettingActions.helmSettingPa
const fetchedHelmMainVersionsQueue = defineActionQueue(AdminHelmSettingActions.helmMainVersionsRetrieved.matches)
const fetchedHelmBuilderVersionsQueue = defineActionQueue(AdminHelmSettingActions.helmBuilderVersionsRetrieved.matches)
const activeRoutesRetrievedQueue = defineActionQueue(AdminActiveRouteActions.activeRoutesRetrieved.matches)
const fetchedInstanceServerQueue = defineActionQueue(InstanceServerSettingActions.fetchedInstanceServer.matches)
const chargebeeSettingRetrievedQueue = defineActionQueue(AdminChargebeeSettingActions.chargebeeSettingRetrieved.matches)
// const authSettingRetrievedQueue = defineActionQueue(AuthSettingsActions.authSettingRetrieved.matches)
// const authSettingPatchedQueue = defineActionQueue(AuthSettingsActions.authSettingPatched.matches)
// const fetchedClientQueue = defineActionQueue(ClientSettingActions.fetchedClient.matches)
// const clientSettingPatchedQueue = defineActionQueue(ClientSettingActions.clientSettingPatched.matches)

const execute = () => {
for (const action of fetchedCoilQueue()) CoilSettingReceptors.fetchedCoilReceptor(action)
Expand All @@ -64,13 +55,8 @@ const execute = () => {
for (const action of fetchedHelmBuilderVersionsQueue())
HelmSettingReceptors.helmBuilderVersionsRetrievedReceptor(action)
for (const action of activeRoutesRetrievedQueue()) AdminActiveRouteReceptors.activeRoutesRetrievedReceptor(action)
for (const action of fetchedInstanceServerQueue()) AdminInstanceServerReceptors.fetchedInstanceServerReceptor(action)
for (const action of chargebeeSettingRetrievedQueue())
AdminChargebeeReceptors.chargebeeSettingRetrievedReceptor(action)
// for (const action of authSettingRetrievedQueue()) // AuthSettingsReceptors.authSettingRetrievedReceptor(action)/ }
// for (const action of authSettingPatchedQueue()) // AuthSettingsReceptors.authSettingPatchedReceptor(action)/ }
// for (const action of fetchedClientQueue()) // ClientSettingReceptors.fetchedClientReceptor(action)/ }
// for (const action of clientSettingPatchedQueue()) // ClientSettingReceptors.clientSettingPatchedReceptor(action)/ }
}

export const AdminSystem = defineSystem({
Expand Down