Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
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,14 +25,13 @@ 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 {
AwsSettingPatch,
awsSettingPath,
AwsSettingType
} from '@etherealengine/engine/src/schemas/setting/aws-setting.schema'
import { defineAction, defineState, dispatchAction, getMutableState } from '@etherealengine/hyperflux'
import { defineState, getMutableState } from '@etherealengine/hyperflux'

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

Expand All @@ -47,46 +46,21 @@ export const AdminAwsSettingState = defineState({
})
})

const awsSettingRetrievedReceptor = (action: typeof AdminAwsSettingActions.awsSettingRetrieved.matches._TYPE) => {
const state = getMutableState(AdminAwsSettingState)
return state.merge({ awsSettings: action.awsSettings.data, updateNeeded: false })
}

const awsSettingPatchedReceptor = (action: typeof AdminAwsSettingActions.awsSettingPatched.matches._TYPE) => {
const state = getMutableState(AdminAwsSettingState)
return state.updateNeeded.set(true)
}

export const AwsSettingReceptors = {
awsSettingRetrievedReceptor,
awsSettingPatchedReceptor
}

export const AwsSettingService = {
fetchAwsSetting: async () => {
try {
const awsSettings = (await Engine.instance.api.service(awsSettingPath).find()) as Paginated<AwsSettingType>
dispatchAction(AdminAwsSettingActions.awsSettingRetrieved({ awsSettings }))
getMutableState(AdminAwsSettingState).merge({ awsSettings: awsSettings.data, updateNeeded: false })
} catch (err) {
NotificationService.dispatchNotify(err.message, { variant: 'error' })
}
},
patchAwsSetting: async (data: AwsSettingPatch, id: string) => {
try {
await Engine.instance.api.service(awsSettingPath).patch(id, data)
dispatchAction(AdminAwsSettingActions.awsSettingPatched({}))
getMutableState(AdminAwsSettingState).merge({ updateNeeded: true })
} catch (err) {
NotificationService.dispatchNotify(err.message, { variant: 'error' })
}
}
}

export class AdminAwsSettingActions {
static awsSettingRetrieved = defineAction({
type: 'ee.client.AdminAwsSetting.ADMIN_AWS_SETTING_FETCHED' as const,
awsSettings: matches.object as Validator<unknown, Paginated<AwsSettingType>>
})
static awsSettingPatched = defineAction({
type: 'ee.client.AdminAwsSetting.ADMIN_AWS_SETTING_PATCHED' as const
})
}
5 changes: 0 additions & 5 deletions packages/client-core/src/systems/AdminSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { defineActionQueue } from '@etherealengine/hyperflux'
import { AdminActiveRouteActions, AdminActiveRouteReceptors } from '../admin/services/ActiveRouteService'
import { AdminSceneActions, AdminSceneReceptors } from '../admin/services/SceneService'
// import { AuthSettingsActions, AuthSettingsReceptors } from '../admin/services/Setting/AuthSettingService'
import { AdminAwsSettingActions, AwsSettingReceptors } from '../admin/services/Setting/AwsSettingService'
import {
AdminChargebeeReceptors,
AdminChargebeeSettingActions
Expand All @@ -52,8 +51,6 @@ import {

const fetchedTaskServersQueue = defineActionQueue(AdminTaskServerSettingActions.fetchedTaskServers.matches)
const redisSettingRetrievedQueue = defineActionQueue(AdminRedisSettingActions.redisSettingRetrieved.matches)
const awsSettingRetrievedQueue = defineActionQueue(AdminAwsSettingActions.awsSettingRetrieved.matches)
const awsSettingPatchedQueue = defineActionQueue(AdminAwsSettingActions.awsSettingPatched.matches)
const fetchedCoilQueue = defineActionQueue(AdminCoilSettingActions.fetchedCoil.matches)
const fetchedEmailQueue = defineActionQueue(EmailSettingActions.fetchedEmail.matches)
const emailSettingPatchedQueue = defineActionQueue(EmailSettingActions.emailSettingPatched.matches)
Expand All @@ -77,8 +74,6 @@ const chargebeeSettingRetrievedQueue = defineActionQueue(AdminChargebeeSettingAc
const execute = () => {
for (const action of fetchedTaskServersQueue()) TaskServerSettingReceptors.fetchedTaskServersReceptor(action)
for (const action of redisSettingRetrievedQueue()) RedisSettingReceptors.redisSettingRetrievedReceptor(action)
for (const action of awsSettingRetrievedQueue()) AwsSettingReceptors.awsSettingRetrievedReceptor(action)
for (const action of awsSettingPatchedQueue()) AwsSettingReceptors.awsSettingPatchedReceptor(action)
for (const action of fetchedCoilQueue()) CoilSettingReceptors.fetchedCoilReceptor(action)
for (const action of fetchedEmailQueue()) EmailSettingReceptors.fetchedEmailReceptor(action)
for (const action of emailSettingPatchedQueue()) EmailSettingReceptors.emailSettingPatchedReceptor(action)
Expand Down