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

Commit

Permalink
refactor(client-core)(instance-server-settings service): remove actio…
Browse files Browse the repository at this point in the history
…n receptor usage (#8354)

Co-authored-by: HexaField <joshfield999@gmail.com>
  • Loading branch information
aditya-mitra and HexaField authored Jul 22, 2023
1 parent 75e2802 commit 90acb6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 35 deletions.
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

0 comments on commit 90acb6c

Please sign in to comment.