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)(task-server-settings service): remove action re…
Browse files Browse the repository at this point in the history
…ceptor usage (#8350)
  • Loading branch information
aditya-mitra authored Jul 22, 2023
1 parent af33f85 commit d49ea32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 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 {
taskServerSettingPath,
TaskServerSettingType
} from '@etherealengine/engine/src/schemas/setting/task-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,31 +42,15 @@ export const AdminTaskServerSettingsState = defineState({
})
})

const fetchedTaskServersReceptor = (action: typeof AdminTaskServerSettingActions.fetchedTaskServers.matches._TYPE) => {
const state = getMutableState(AdminTaskServerSettingsState)
return state.merge({ taskservers: action.taskServerSettings.data, updateNeeded: false })
}

export const TaskServerSettingReceptors = {
fetchedTaskServersReceptor
}

export const AdminSettingTaskServerService = {
fetchSettingsTaskServer: async (inDec?: 'increment' | 'decrement') => {
fetchSettingsTaskServer: async () => {
try {
const taskServerSettings = (await Engine.instance.api
.service(taskServerSettingPath)
.find()) as Paginated<TaskServerSettingType>
dispatchAction(AdminTaskServerSettingActions.fetchedTaskServers({ taskServerSettings }))
getMutableState(AdminTaskServerSettingsState).merge({ taskservers: taskServerSettings.data, updateNeeded: false })
} catch (err) {
NotificationService.dispatchNotify(err.message, { variant: 'error' })
}
}
}

export class AdminTaskServerSettingActions {
static fetchedTaskServers = defineAction({
type: 'ee.client.AdminTaskServerSetting.SETTING_ANALYIS_DISPLAY' as const,
taskServerSettings: matches.object as Validator<unknown, Paginated<TaskServerSettingType>>
})
}
6 changes: 0 additions & 6 deletions packages/client-core/src/systems/AdminSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ import {
import { AdminProjectSettingsActions, ProjectSettingReceptors } from '../admin/services/Setting/ProjectSettingService'
import { AdminRedisSettingActions, RedisSettingReceptors } from '../admin/services/Setting/RedisSettingService'
import { AdminServerSettingActions, ServerSettingReceptors } from '../admin/services/Setting/ServerSettingService'
import {
AdminTaskServerSettingActions,
TaskServerSettingReceptors
} from '../admin/services/Setting/TaskServerSettingsService'

const fetchedTaskServersQueue = defineActionQueue(AdminTaskServerSettingActions.fetchedTaskServers.matches)
const redisSettingRetrievedQueue = defineActionQueue(AdminRedisSettingActions.redisSettingRetrieved.matches)
const fetchedCoilQueue = defineActionQueue(AdminCoilSettingActions.fetchedCoil.matches)
const fetchedEmailQueue = defineActionQueue(EmailSettingActions.fetchedEmail.matches)
Expand All @@ -69,7 +64,6 @@ const chargebeeSettingRetrievedQueue = defineActionQueue(AdminChargebeeSettingAc
// const clientSettingPatchedQueue = defineActionQueue(ClientSettingActions.clientSettingPatched.matches)

const execute = () => {
for (const action of fetchedTaskServersQueue()) TaskServerSettingReceptors.fetchedTaskServersReceptor(action)
for (const action of redisSettingRetrievedQueue()) RedisSettingReceptors.redisSettingRetrievedReceptor(action)
for (const action of fetchedCoilQueue()) CoilSettingReceptors.fetchedCoilReceptor(action)
for (const action of fetchedEmailQueue()) EmailSettingReceptors.fetchedEmailReceptor(action)
Expand Down

0 comments on commit d49ea32

Please sign in to comment.