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

refactor(client-core)(coil-settings service): remove action receptor usage #8345

Merged
merged 3 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,10 +25,9 @@ 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 { coilSettingPath, CoilSettingType } from '@etherealengine/engine/src/schemas/setting/coil-setting.schema'
import { defineAction, defineState, dispatchAction, getMutableState } from '@etherealengine/hyperflux'
import { defineState, getMutableState } from '@etherealengine/hyperflux'

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

Expand All @@ -40,29 +39,13 @@ export const AdminCoilSettingsState = defineState({
})
})

const fetchedCoilReceptor = (action: typeof AdminCoilSettingActions.fetchedCoil.matches._TYPE) => {
const state = getMutableState(AdminCoilSettingsState)
return state.merge({ coil: action.coilSettings.data, updateNeeded: false })
}

export const CoilSettingReceptors = {
fetchedCoilReceptor
}

export const AdminCoilSettingService = {
fetchCoil: async () => {
try {
const coilSettings = (await Engine.instance.api.service(coilSettingPath).find()) as Paginated<CoilSettingType>
dispatchAction(AdminCoilSettingActions.fetchedCoil({ coilSettings }))
getMutableState(AdminCoilSettingsState).merge({ coil: coilSettings.data, updateNeeded: false })
} catch (err) {
NotificationService.dispatchNotify(err.message, { variant: 'error' })
}
}
}

export class AdminCoilSettingActions {
static fetchedCoil = defineAction({
type: 'ee.client.AdminCoilSetting.COIL_SETTING_DISPLAY' as const,
coilSettings: matches.object as Validator<unknown, Paginated<CoilSettingType>>
})
}
3 changes: 0 additions & 3 deletions packages/client-core/src/systems/AdminSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ import {
AdminChargebeeReceptors,
AdminChargebeeSettingActions
} from '../admin/services/Setting/ChargebeeSettingService'
import { AdminCoilSettingActions, CoilSettingReceptors } from '../admin/services/Setting/CoilSettingService'
import { EmailSettingActions, EmailSettingReceptors } from '../admin/services/Setting/EmailSettingService'
import { AdminHelmSettingActions, HelmSettingReceptors } from '../admin/services/Setting/HelmSettingService'

const fetchedCoilQueue = defineActionQueue(AdminCoilSettingActions.fetchedCoil.matches)
const fetchedEmailQueue = defineActionQueue(EmailSettingActions.fetchedEmail.matches)
const emailSettingPatchedQueue = defineActionQueue(EmailSettingActions.emailSettingPatched.matches)
const fetchedHelmQueue = defineActionQueue(AdminHelmSettingActions.helmSettingRetrieved.matches)
Expand All @@ -46,7 +44,6 @@ const activeRoutesRetrievedQueue = defineActionQueue(AdminActiveRouteActions.act
const chargebeeSettingRetrievedQueue = defineActionQueue(AdminChargebeeSettingActions.chargebeeSettingRetrieved.matches)

const execute = () => {
for (const action of fetchedCoilQueue()) CoilSettingReceptors.fetchedCoilReceptor(action)
for (const action of fetchedEmailQueue()) EmailSettingReceptors.fetchedEmailReceptor(action)
for (const action of emailSettingPatchedQueue()) EmailSettingReceptors.emailSettingPatchedReceptor(action)
for (const action of fetchedHelmQueue()) HelmSettingReceptors.helmSettingRetrievedReceptor(action)
Expand Down