From 9ea928c5d9974df246f8adf47b4e80e3d60c3cb5 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com> Date: Wed, 5 Feb 2025 02:47:53 +0400 Subject: [PATCH] fix: rename params to skinSettings to follow hub convention --- src/helpers/actions.ts | 10 +++++----- src/writer/settings.ts | 2 +- test/integration/helpers/actions.test.ts | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/helpers/actions.ts b/src/helpers/actions.ts index 48c566a8..6fca5d2c 100644 --- a/src/helpers/actions.ts +++ b/src/helpers/actions.ts @@ -15,7 +15,7 @@ function normalizeSettings(settings: any) { }; } - delete _settings.skinParams; + delete _settings.skinSettings; return _settings; } @@ -44,11 +44,11 @@ export async function addOrUpdateSpace(id: string, settings: any) { normalizedSettings.domain || null ]); - await addOrUpdateSkin(id, settings.skinParams); + await addOrUpdateSkin(id, settings.skinSettings); } -export async function addOrUpdateSkin(id: string, skinParams: Record) { - if (!skinParams) return false; +export async function addOrUpdateSkin(id: string, skinSettings: Record) { + if (!skinSettings) return false; const COLORS = [ 'bg_color', @@ -61,7 +61,7 @@ export async function addOrUpdateSkin(id: string, skinParams: Record { if (_params[color]) { _params[color] = _params[color].replace('#', ''); diff --git a/src/writer/settings.ts b/src/writer/settings.ts index e43df26e..fbe34134 100644 --- a/src/writer/settings.ts +++ b/src/writer/settings.ts @@ -84,7 +84,7 @@ export async function verify(body): Promise { if (!space?.turbo && !space?.domain) { if (msg.payload.domain) return Promise.reject('domain is a turbo feature only'); - if (msg.payload.skinParams) return Promise.reject('skin is a turbo feature only'); + if (msg.payload.skinSettings) return Promise.reject('skin is a turbo feature only'); } const anotherSpaceWithDomain = ( diff --git a/test/integration/helpers/actions.test.ts b/test/integration/helpers/actions.test.ts index b1b72f60..6d820e13 100644 --- a/test/integration/helpers/actions.test.ts +++ b/test/integration/helpers/actions.test.ts @@ -179,7 +179,7 @@ describe('helpers/actions', () => { it('adds a new skin when it does not exist', async () => { const testId = 'test-new-skin-ids'; - const skinParams = { + const skinSettings = { bg_color: '#000000', link_color: '#ffffff', text_color: '#000000', @@ -188,7 +188,7 @@ describe('helpers/actions', () => { heading_color: '#ffffff', primary_color: '#ffffff' }; - await addOrUpdateSkin(testId, skinParams); + await addOrUpdateSkin(testId, skinSettings); const skin = (await db.queryAsync('SELECT * FROM skins WHERE id = ?', [testId]))[0]; expect(skin).toEqual({ id: testId, @@ -206,7 +206,7 @@ describe('helpers/actions', () => { it('updates an existing skin', async () => { const testId = 'test-update-skin-id'; - const skinParams = { + const skinSettings = { bg_color: '#FFFF00', link_color: '#FFFFFF' }; @@ -225,7 +225,7 @@ describe('helpers/actions', () => { 'light' ] ); - await addOrUpdateSkin(testId, skinParams); + await addOrUpdateSkin(testId, skinSettings); const skin = (await db.queryAsync('SELECT * FROM skins WHERE id = ?', [testId]))[0]; expect(skin).toEqual({ id: testId,