From cfdc9e3d1c552406bd617650c668b3fd36fb75bb Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Wed, 7 Aug 2024 11:12:02 +0200 Subject: [PATCH 1/3] Code style fixes --- lib/Controller/CatalogiController.php | 10 ++--- lib/Controller/DirectoryController.php | 12 +++--- lib/Controller/MetaDataController.php | 12 +++--- lib/Controller/OrganisationsController.php | 42 +++++---------------- lib/Controller/PublicationsController.php | 12 +++--- lib/Controller/SearchController.php | 6 +-- lib/Controller/ThemesController.php | 44 ++++++---------------- 7 files changed, 47 insertions(+), 91 deletions(-) diff --git a/lib/Controller/CatalogiController.php b/lib/Controller/CatalogiController.php index f0217df7..982c5bd2 100644 --- a/lib/Controller/CatalogiController.php +++ b/lib/Controller/CatalogiController.php @@ -45,15 +45,15 @@ public function index(ObjectService $objectService, SearchService $searchService if($this->config->hasKey($this->appName, 'mongoStorage') === false || $this->config->getValueString($this->appName, 'mongoStorage') !== '1' ) { - $searchParams = $searchService->createMySQLSearchParams($filters, $fieldsToSearch); - $searchConditions = $searchService->createMySQLSearchConditions($filters, $fieldsToSearch); + $searchParams = $searchService->createMySQLSearchParams(filters: $filters); + $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); $filters = $searchService->unsetSpecialQueryParams($filters); - return new JSONResponse(['results' => $this->catalogMapper->findAll(filters: $filters, searchParams: $searchParams, searchConditions: $searchConditions)]); + return new JSONResponse(['results' => $this->catalogMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } - $filters = $searchService->createMongoDBSearchFilter($filters, $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters, $fieldsToSearch); + $filters = $searchService->createMongoDBSearchFilter(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); try { $dbConfig = [ diff --git a/lib/Controller/DirectoryController.php b/lib/Controller/DirectoryController.php index 6d9c5dd3..77b383eb 100644 --- a/lib/Controller/DirectoryController.php +++ b/lib/Controller/DirectoryController.php @@ -97,15 +97,15 @@ public function index(ObjectService $objectService, SearchService $searchService if($this->config->hasKey($this->appName, 'mongoStorage') === false || $this->config->getValueString($this->appName, 'mongoStorage') !== '1' ) { - $searchParams = $searchService->createMySQLSearchParams($filters, $fieldsToSearch); - $searchConditions = $searchService->createMySQLSearchConditions($filters, $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters, $fieldsToSearch); + $searchParams = $searchService->createMySQLSearchParams(filters: $filters); + $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); - return new JSONResponse(['results' => $this->listingMapper->findAll(filters: $filters, searchParams: $searchParams, searchConditions: $searchConditions)]); + return new JSONResponse(['results' => $this->listingMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } - $filters = $searchService->createMongoDBSearchFilter($filters, $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters, $fieldsToSearch); + $filters = $searchService->createMongoDBSearchFilter(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); diff --git a/lib/Controller/MetaDataController.php b/lib/Controller/MetaDataController.php index b2f9cdf8..8b2c8268 100644 --- a/lib/Controller/MetaDataController.php +++ b/lib/Controller/MetaDataController.php @@ -53,15 +53,15 @@ public function index(ObjectService $objectService, SearchService $searchService if($this->config->hasKey($this->appName, 'mongoStorage') === false || $this->config->getValueString($this->appName, 'mongoStorage') !== '1' ) { - $searchParams = $searchService->createMySQLSearchParams($filters, $fieldsToSearch); - $searchConditions = $searchService->createMySQLSearchConditions($filters, $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters, $fieldsToSearch); + $searchParams = $searchService->createMySQLSearchParams(filters: $filters); + $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); - return new JSONResponse(['results' =>$this->metaDataMapper->findAll(filters: $filters, searchParams: $searchParams, searchConditions: $searchConditions)]); + return new JSONResponse(['results' =>$this->metaDataMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } - $filters = $searchService->createMongoDBSearchFilter($filters, $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters, $fieldsToSearch); + $filters = $searchService->createMongoDBSearchFilter(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); diff --git a/lib/Controller/OrganisationsController.php b/lib/Controller/OrganisationsController.php index 3a8d6cf6..04cbbaf8 100644 --- a/lib/Controller/OrganisationsController.php +++ b/lib/Controller/OrganisationsController.php @@ -5,6 +5,7 @@ use OCA\OpenCatalogi\Db\OrganisationMapper; use OCA\OpenCatalogi\Service\ObjectService; use OCP\AppFramework\Controller; +use OCA\OpenCatalogi\Service\SearchService; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\JSONResponse; use OCP\IAppConfig; @@ -44,47 +45,24 @@ public function page(): TemplateResponse * * @return JSONResponse */ - public function index(ObjectService $objectService): JSONResponse + public function index(ObjectService $objectService, SearchService $searchService): JSONResponse { - $filters = $this->request->getParams(); - - $searchConditions = []; - $searchParams = []; $fieldsToSearch = ['title', 'description', 'summary']; - foreach ($filters as $key => $value) { - if ($key === '_search') { - // MongoDB - $searchRegex = ['$regex' => $value, '$options' => 'i']; - $filters['$or'] = []; - - // MySQL - $searchParams['search'] = '%' . strtolower($value) . '%'; - - foreach ($fieldsToSearch as $field) { - // MongoDB - $filters['$or'][] = [$field => $searchRegex]; - - // MySQL - $searchConditions[] = "LOWER($field) LIKE :search"; - } - } - - if (str_starts_with($key, '_')) { - unset($filters[$key]); - } - } - if($this->config->hasKey($this->appName, 'mongoStorage') === false || $this->config->getValueString($this->appName, 'mongoStorage') !== '1' ) { - // Unset mongodb filter - unset($filters['$or']); + $searchParams = $searchService->createMySQLSearchParams(filters: $filters); + $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); - return new JSONResponse(['results' => $this->organisationMapper->findAll(filters: $filters, searchParams: $searchParams, searchConditions: $searchConditions)]); + return new JSONResponse(['results' => $this->organisationMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } - + + $filters = $searchService->createMongoDBSearchFilter(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); + try { $dbConfig = [ 'base_uri' => $this->config->getValueString($this->appName, 'mongodbLocation'), diff --git a/lib/Controller/PublicationsController.php b/lib/Controller/PublicationsController.php index 05f9dd67..6041059b 100644 --- a/lib/Controller/PublicationsController.php +++ b/lib/Controller/PublicationsController.php @@ -119,15 +119,15 @@ public function index(ObjectService $objectService, SearchService $searchService if($this->config->hasKey($this->appName, 'mongoStorage') === false || $this->config->getValueString($this->appName, 'mongoStorage') !== '1' ) { - $searchParams = $searchService->createMySQLSearchParams($filters, $fieldsToSearch); - $searchConditions = $searchService->createMySQLSearchConditions($filters, $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters, $fieldsToSearch); + $searchParams = $searchService->createMySQLSearchParams(filters: $filters); + $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); - return new JSONResponse(['results' => $this->publicationMapper->findAll(filters: $filters, searchParams: $searchParams, searchConditions: $searchConditions)]); + return new JSONResponse(['results' => $this->publicationMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } - $filters = $searchService->createMongoDBSearchFilter($filters, $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters, $fieldsToSearch); + $filters = $searchService->createMongoDBSearchFilter(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); $dbConfig['base_uri'] = $this->config->getValueString(app: $this->appName, key: 'mongodbLocation'); $dbConfig['headers']['api-key'] = $this->config->getValueString(app: $this->appName, key: 'mongodbKey'); diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php index 7fc12b75..ad8867d7 100644 --- a/lib/Controller/SearchController.php +++ b/lib/Controller/SearchController.php @@ -74,11 +74,11 @@ public function index(SearchService $searchService): JSONResponse if($this->config->hasKey($this->appName, 'mongoStorage') === false || $this->config->getValueString($this->appName, 'mongoStorage') !== '1' ) { - $searchParams = $searchService->createMySQLSearchParams($filters, $fieldsToSearch); - $searchConditions = $searchService->createMySQLSearchConditions($filters, $fieldsToSearch); + $searchParams = $searchService->createMySQLSearchParams(filters: $filters); + $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); $filters = $searchService->unsetSpecialQueryParams($filters); - return new JSONResponse(['results' => $this->publicationMapper->findAll(filters: $filters, searchParams: $searchParams, searchConditions: $searchConditions)]); + return new JSONResponse(['results' => $this->publicationMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } //@TODO: find a better way to get query params. This fixes it for now. diff --git a/lib/Controller/ThemesController.php b/lib/Controller/ThemesController.php index 2508bdb3..3e519a2f 100644 --- a/lib/Controller/ThemesController.php +++ b/lib/Controller/ThemesController.php @@ -4,6 +4,7 @@ use OCA\OpenCatalogi\Db\ThemeMapper; use OCA\OpenCatalogi\Service\ObjectService; +use OCA\OpenCatalogi\Service\SearchService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\JSONResponse; @@ -58,47 +59,24 @@ public function page(): TemplateResponse * * @return JSONResponse */ - public function index(ObjectService $objectService): JSONResponse + public function index(ObjectService $objectService, SearchService $searchService): JSONResponse { - $filters = $this->request->getParams(); - - $searchConditions = []; - $searchParams = []; $fieldsToSearch = ['title', 'description', 'summary']; - foreach ($filters as $key => $value) { - if ($key === '_search') { - // MongoDB - $searchRegex = ['$regex' => $value, '$options' => 'i']; - $filters['$or'] = []; - - // MySQL - $searchParams['search'] = '%' . strtolower($value) . '%'; - - foreach ($fieldsToSearch as $field) { - // MongoDB - $filters['$or'][] = [$field => $searchRegex]; - - // MySQL - $searchConditions[] = "LOWER($field) LIKE :search"; - } - } - - if (str_starts_with($key, '_')) { - unset($filters[$key]); - } - } - if($this->config->hasKey($this->appName, 'mongoStorage') === false || $this->config->getValueString($this->appName, 'mongoStorage') !== '1' ) { - // Unset mongodb filter - unset($filters['$or']); + $searchParams = $searchService->createMySQLSearchParams(filters: $filters); + $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams($filters); - return new JSONResponse(['results' => $this->themeMapper->findAll(filters: $filters, searchParams: $searchParams, searchConditions: $searchConditions)]); + return new JSONResponse(['results' => $this->themeMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } - + + $filters = $searchService->createMongoDBSearchFilter(filters: $filters, fieldsToSearch: $fieldsToSearch); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); + try { $dbConfig = [ 'base_uri' => $this->config->getValueString($this->appName, 'mongodbLocation'), @@ -160,7 +138,7 @@ public function show(string $id, ObjectService $objectService): JSONResponse */ public function create(ObjectService $objectService): JSONResponse { - + $data = $this->request->getParams(); foreach ($data as $key => $value) { From ab5586fbd19a8575bee0bb6837bfc321719adf93 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Wed, 7 Aug 2024 11:13:04 +0200 Subject: [PATCH 2/3] Small argument fix --- lib/Controller/CatalogiController.php | 2 +- lib/Controller/SearchController.php | 2 +- lib/Controller/ThemesController.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Controller/CatalogiController.php b/lib/Controller/CatalogiController.php index 982c5bd2..855133fe 100644 --- a/lib/Controller/CatalogiController.php +++ b/lib/Controller/CatalogiController.php @@ -47,7 +47,7 @@ public function index(ObjectService $objectService, SearchService $searchService ) { $searchParams = $searchService->createMySQLSearchParams(filters: $filters); $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); return new JSONResponse(['results' => $this->catalogMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php index ad8867d7..27732845 100644 --- a/lib/Controller/SearchController.php +++ b/lib/Controller/SearchController.php @@ -76,7 +76,7 @@ public function index(SearchService $searchService): JSONResponse ) { $searchParams = $searchService->createMySQLSearchParams(filters: $filters); $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); return new JSONResponse(['results' => $this->publicationMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } diff --git a/lib/Controller/ThemesController.php b/lib/Controller/ThemesController.php index 3e519a2f..308c92c6 100644 --- a/lib/Controller/ThemesController.php +++ b/lib/Controller/ThemesController.php @@ -69,7 +69,7 @@ public function index(ObjectService $objectService, SearchService $searchService ) { $searchParams = $searchService->createMySQLSearchParams(filters: $filters); $searchConditions = $searchService->createMySQLSearchConditions(filters: $filters, fieldsToSearch: $fieldsToSearch); - $filters = $searchService->unsetSpecialQueryParams($filters); + $filters = $searchService->unsetSpecialQueryParams(filters: $filters); return new JSONResponse(['results' => $this->themeMapper->findAll(limit: null, offset: null, filters: $filters, searchConditions: $searchConditions, searchParams: $searchParams)]); } From b0376f5ca5841369b8b8a2073f2a7df32cda5cd5 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 7 Aug 2024 09:15:03 +0000 Subject: [PATCH 3/3] Update src from PHP Codesniffer --- src/store/modules/configuration.js | 10 +++++----- src/store/modules/configuration.spec.js | 10 +++++----- src/store/modules/configuration.specs.js | 12 ++++++------ src/store/modules/metadata.js | 14 +++++++------- src/store/modules/metadata.spec.js | 16 ++++++++-------- src/store/modules/organisation.js | 10 +++++----- src/store/modules/organisation.spec.js | 12 ++++++------ src/store/modules/search.js | 20 ++++++++++---------- src/store/modules/theme.js | 10 +++++----- src/store/modules/theme.spec.js | 12 ++++++------ 10 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/store/modules/configuration.js b/src/store/modules/configuration.js index d4561a4b..a1cb0449 100644 --- a/src/store/modules/configuration.js +++ b/src/store/modules/configuration.js @@ -27,16 +27,16 @@ export const useConfigurationStore = defineStore( ) .then( (response) => { - response.json().then( - (data) => { - this.setConfigurationItem(data) + response.json().then( + (data) => { + this.setConfigurationItem(data) } - ) + ) } ) .catch( (err) => { - console.error(err) + console.error(err) } ) }, diff --git a/src/store/modules/configuration.spec.js b/src/store/modules/configuration.spec.js index 814184e0..674586b6 100644 --- a/src/store/modules/configuration.spec.js +++ b/src/store/modules/configuration.spec.js @@ -5,15 +5,15 @@ import { useConfigurationStore } from './configuration.js' describe( 'Configuration Store', () => { - beforeEach( - () => { - setActivePinia(createPinia()) + beforeEach( + () => { + setActivePinia(createPinia()) } - ) + ) it( 'sets configuration item correctly', () => { - const store = useConfigurationStore() + const store = useConfigurationStore() store.setConfigurationItem(mockConfiguration()[0]) diff --git a/src/store/modules/configuration.specs.js b/src/store/modules/configuration.specs.js index 62920f59..aeb143d3 100644 --- a/src/store/modules/configuration.specs.js +++ b/src/store/modules/configuration.specs.js @@ -6,15 +6,15 @@ import { useConfigurationStore } from './configuration.js'; describe( 'Metadata Store', () => { - beforeEach( - () => { - setActivePinia(createPinia()) + beforeEach( + () => { + setActivePinia(createPinia()) } - ) + ) it( 'sets configuration item correctly', () => { - const store = useConfigurationStore() + const store = useConfigurationStore() store.setConfigurationItem(testData[0]) @@ -38,7 +38,7 @@ describe( it( 'sets configuration list correctly', () => { - const store = useConfigurationStore() + const store = useConfigurationStore() store.setConfigurationItem(testData) diff --git a/src/store/modules/metadata.js b/src/store/modules/metadata.js index 0de1c28e..cb8c0ffd 100644 --- a/src/store/modules/metadata.js +++ b/src/store/modules/metadata.js @@ -41,19 +41,19 @@ export const useMetadataStore = defineStore( ) .then( (response) => { - response.json().then( - (data) => { - this.metaDataList = data.results.map( - (metadataItem) => new Metadata(metadataItem), - ) + response.json().then( + (data) => { + this.metaDataList = data.results.map( + (metadataItem) => new Metadata(metadataItem), + ) return data } - ) + ) } ) .catch( (err) => { - console.error(err) + console.error(err) return err } ) diff --git a/src/store/modules/metadata.spec.js b/src/store/modules/metadata.spec.js index 38b1a8ab..514b5062 100644 --- a/src/store/modules/metadata.spec.js +++ b/src/store/modules/metadata.spec.js @@ -6,15 +6,15 @@ import { Metadata, mockMetadata } from '../../entities/index.js' describe( 'Metadata Store', () => { - beforeEach( - () => { - setActivePinia(createPinia()) + beforeEach( + () => { + setActivePinia(createPinia()) } - ) + ) it( 'sets metadata item correctly', () => { - const store = useMetadataStore() + const store = useMetadataStore() store.setMetaDataItem(mockMetadata()[0]) @@ -27,7 +27,7 @@ describe( it( 'sets metadata item with string "properties" property', () => { - const store = useMetadataStore() + const store = useMetadataStore() // stringify json data const mockData = mockMetadata()[0] @@ -44,7 +44,7 @@ describe( it( 'sets metadata list correctly', () => { - const store = useMetadataStore() + const store = useMetadataStore() store.setMetaDataList(mockMetadata()) @@ -57,7 +57,7 @@ describe( it( 'get metadata property from key', () => { - const store = useMetadataStore() + const store = useMetadataStore() store.setMetaDataItem(mockMetadata()[0]) store.setMetadataDataKey('test') diff --git a/src/store/modules/organisation.js b/src/store/modules/organisation.js index 3844677c..61b952b7 100644 --- a/src/store/modules/organisation.js +++ b/src/store/modules/organisation.js @@ -33,16 +33,16 @@ export const useOrganisationStore = defineStore( ) .then( (response) => { - response.json().then( - (data) => { - this.setOrganisationList(data.results) + response.json().then( + (data) => { + this.setOrganisationList(data.results) } - ) + ) } ) .catch( (err) => { - console.error(err) + console.error(err) } ) }, diff --git a/src/store/modules/organisation.spec.js b/src/store/modules/organisation.spec.js index b14a260b..27385c8e 100644 --- a/src/store/modules/organisation.spec.js +++ b/src/store/modules/organisation.spec.js @@ -6,15 +6,15 @@ import { useOrganisationStore } from './organisation.js'; describe( 'Organisation Store', () => { - beforeEach( - () => { - setActivePinia(createPinia()) + beforeEach( + () => { + setActivePinia(createPinia()) } - ) + ) it( 'sets organisation item correctly', () => { - const store = useOrganisationStore() + const store = useOrganisationStore() store.setOrganisationItem(mockOrganisation()[0]) @@ -38,7 +38,7 @@ describe( it( 'sets organisation list correctly', () => { - const store = useOrganisationStore() + const store = useOrganisationStore() store.setOrganisationList(mockOrganisation()) diff --git a/src/store/modules/search.js b/src/store/modules/search.js index cd1a532b..db326f1e 100644 --- a/src/store/modules/search.js +++ b/src/store/modules/search.js @@ -27,22 +27,22 @@ export const useSearchStore = defineStore( ) .then( (response) => { - response.json().then( - (data) => { - if (data?.code === 403 && data?.message) { - this.searchError = data.message - console.log(this.searchError) - } else { - this.searchError = '' // Clear any previous errors - } + response.json().then( + (data) => { + if (data?.code === 403 && data?.message) { + this.searchError = data.message + console.log(this.searchError) + } else { + this.searchError = '' // Clear any previous errors + } this.searchResults = data } - ) + ) } ) .catch( (err) => { - this.searchError = err.message || 'An error occurred' + this.searchError = err.message || 'An error occurred' console.error(err.message ?? err) } ) diff --git a/src/store/modules/theme.js b/src/store/modules/theme.js index 0cecf1b0..e7fe9bd1 100644 --- a/src/store/modules/theme.js +++ b/src/store/modules/theme.js @@ -33,16 +33,16 @@ export const useThemeStore = defineStore( ) .then( (response) => { - response.json().then( - (data) => { - this.setThemeList(data.results) + response.json().then( + (data) => { + this.setThemeList(data.results) } - ) + ) } ) .catch( (err) => { - console.error(err) + console.error(err) } ) }, diff --git a/src/store/modules/theme.spec.js b/src/store/modules/theme.spec.js index cb7b85cc..34931d81 100644 --- a/src/store/modules/theme.spec.js +++ b/src/store/modules/theme.spec.js @@ -6,15 +6,15 @@ import { mockTheme, Theme } from '../../entities/index.js' describe( 'Theme Store', () => { - beforeEach( - () => { - setActivePinia(createPinia()) + beforeEach( + () => { + setActivePinia(createPinia()) } - ) + ) it( 'sets theme item correctly', () => { - const store = useThemeStore() + const store = useThemeStore() store.setThemeItem(mockTheme()[0]) @@ -38,7 +38,7 @@ describe( it( 'sets theme list correctly', () => { - const store = useThemeStore() + const store = useThemeStore() store.setThemeList(mockTheme())