Skip to content

Commit

Permalink
♻️ refactor(db.ts): replace custom shuffle with lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinsOnuoha committed Oct 28, 2023
1 parent b582f9e commit d9a60a6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"@vueuse/core": "^10.5.0",
"click-outside-vue3": "^4.0.1",
"lodash.shuffle": "^4.2.0",
"pinia": "^2.1.7",
"vue": "^3.3.4",
"vue-router": "^4.2.5"
Expand All @@ -36,6 +37,7 @@
"@rushstack/eslint-patch": "^1.3.3",
"@tsconfig/node18": "^18.2.2",
"@types/jsdom": "^21.1.3",
"@types/lodash.shuffle": "^4.2.8",
"@types/node": "^18.18.5",
"@vitejs/plugin-vue": "^4.4.0",
"@vue/eslint-config-prettier": "^8.0.0",
Expand Down
15 changes: 7 additions & 8 deletions src/stores/db.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { defineStore } from 'pinia'
import statements from './statements.db'
import categories from './categories.db'
import { shuffle } from '@/utils/util'
// import { shuffle } from '@/utils/util'
import shuffle from 'lodash.shuffle'

export type Statement = {
title: string
Expand All @@ -15,15 +16,13 @@ export type Category = {
emoji: string
}
export const useDBStore = defineStore('db', {
state: () => {
return {
categories: categories.data,
statements: statements.data
}
},
state: () => ({
categories: categories.data,
statements: statements.data
}),
getters: {
formattedStatements: (state) => {
return [...new Set(shuffle(state.statements))]
return [...new Set(shuffle(state.statements))] as Statement[]
}
}
})
1 change: 1 addition & 0 deletions src/types/click-outside.d.ts → src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
declare module 'click-outside-vue3'
declare module 'lodash.shuffle'

0 comments on commit d9a60a6

Please sign in to comment.