From 0f5f0d7c6685e15a369b04fc648f08437d38cbf1 Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Wed, 13 Oct 2021 20:49:48 +0200 Subject: [PATCH] Change other state when the other is updated --- app/Controllers/Http/StatesController.ts | 1 + app/Tasks/StatesTask.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/app/Controllers/Http/StatesController.ts b/app/Controllers/Http/StatesController.ts index 447360a..7bd2269 100644 --- a/app/Controllers/Http/StatesController.ts +++ b/app/Controllers/Http/StatesController.ts @@ -19,6 +19,7 @@ export default class StatesController { public async setSleeping ({ request, response }: HttpContextContract) { const { value } = await request.validate(StateSleepingValidator) await Redis.set('states:sleeping', String(value)) + await Redis.set('states:developing', String(!value)) return response.status(200).send({ message: 'State was successfully set!', value: this.formatValue(String(value)) diff --git a/app/Tasks/StatesTask.ts b/app/Tasks/StatesTask.ts index 5fd2b81..e613ea7 100644 --- a/app/Tasks/StatesTask.ts +++ b/app/Tasks/StatesTask.ts @@ -30,6 +30,7 @@ async function getCurrentTime(): Promise { if (redis_state !== active) { await Redis.set('states:developing', String(active)) + await Redis.set('states:sleeping', String(!active)) } } }