Skip to content

Commit

Permalink
add Italian options and speakers, fix adding card's validation, add L…
Browse files Browse the repository at this point in the history
…S history for cards progress, add search for translate
  • Loading branch information
shestmintsev-kirill committed Jul 6, 2023
1 parent fc185c8 commit 2d128f6
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 87 deletions.
86 changes: 43 additions & 43 deletions .firebase/hosting.ZGlzdA.cache
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
index.html,1688152134620,731a661b38fbe0b812cf1e98bbc2b94d378b1e98dce6f49e57eff707f414a4d8
favicon.svg,1688152134604,f0b09d009aefe2b728c79ca5c6b284efc6e23cbb675d86f12d4bc5ddf245274e
service-worker.js,1688152134620,c77f5144a1253ead60c0254388e0547c1198102241f822337099c522051ea02f
manifest.json,1688152134603,91eaecfadc95cc9683074360cd9c6a8da54c20b945ba63a7aee98eb8043bdcd6
robots.txt,1688152134604,c17e70846d7031bb27102edfb33b59d1e3e40a8e8e8097af75b7766e7fffc250
favicon.ico,1688152134604,1e71457865f706dc865b49a54a86e193818220d290b30226b6630a42faf1535d
css/596.49a88333.css,1688152134604,a931f984ea4a02befb56e03f18ff0676dab99860f03134ce58530b74fe0fd51f
css/965.ac1019fb.css,1688152134604,71f2ba508395409211d507e41d547c272cad20706385f02ad5b9ae3c76e17e4d
service-worker.js.map,1688152134621,9a547ecaa8d64051c02e44bb744ef14cabfcc7594fbc33405b28cbf4349faf48
workbox-5b385ed2.js,1688152134621,f66c7dd07974e2f6cd0044dd11b895814d60705007cb8e0d6e3fc74b8ebdbef8
img/google-icon.c43e43a7.svg,1688152134604,4f74694f3fe10f89ab27082b1e6deae549279eb8f2c6e239063078e82860e060
img/icons/android-chrome-192x192.png,1688152134605,97e1127ad8db90e0349c838ecf9351fc0c370f9606f6ab309fe17444d26a9d59
img/icons/android-chrome-maskable-192x192.png,1688152134605,13d1c57561a4e596cc6b6eac9dcc101241daa58e3788850099d293a5cc5f6e80
img/icons/apple-touch-icon-180x180.png,1688152134605,ca5a8e637d730848e77716ed970da1a4a5fe9d3b4be21e43f33cf5ebcaf03e7d
img/icons/apple-touch-icon-120x120.png,1688152134605,13e4908bb32e2ca95e375ca720887ef85057fb3872d6f028c63ba22df9b12ed9
img/icons/apple-touch-icon-152x152.png,1688152134605,879d14ef1bd94f81c11ca6fa51ebca226bf6c88c86447aaf560752528e144067
img/icons/apple-touch-icon-60x60.png,1688152134605,a27014cb4410df491f64e3b5411987418ff6d729b351056a3de84e744c681a52
img/icons/apple-touch-icon.png,1688152134605,08b37da608cf827a037d8f600a01a32b2f74728291e679b03679fd3619da3a43
img/icons/apple-touch-icon-76x76.png,1688152134605,65d6c498ad60f94b338df3f1f4551303ec84306ecb1c7e615ed64489fffc8b28
img/icons/favicon.svg,1688152134605,f0b09d009aefe2b728c79ca5c6b284efc6e23cbb675d86f12d4bc5ddf245274e
img/icons/favicon-32x32.png,1688152134605,f5a182df55d21b93c27ec89bd600abe40f3fac23df563e4cfc9efd5edd248886
img/icons/msapplication-icon-144x144.png,1688152134605,27b3b62de2e36ac452e86079762d3cfd37c33dc8cbde0a7c5657e5a7c32d971a
img/icons/safari-pinned-tab.svg,1688152134620,b96c516490acd2efe112a91da5af4fcb45188808bb3a22c4f05acbe781b2b2b2
img/icons/mstile-150x150.png,1688152134605,ea1dc2c1c63ffe2668cacc9d170cee33b50a2d58e1591b8399004629e3c1ae67
js/596.490767ac.js,1688152134604,57946407774c34ef89600ac3707f49ddccc4422dbd082c44bb2b92d70c170f78
js/5.8b6e5d16.js,1688152134604,a7ad8a64d6de9681c71964f0c4b5da7b9f954b46b7d6a454a4bf08a22afda4d9
js/756.0eb0c08f.js,1688152134604,acccb21381f634497ed4a6cbae090f0dda72325b6c95e53fac33484d226c0a01
js/965.d0f02cb2.js,1688152134604,a25885aad8f08bcfd3ddc9d67290b109c87cd63cb0381e27a07cac67dca6fab8
img/icons/favicon-16x16.png,1688152134605,563096b119e9b3f8060292a6fc3e091e2a98ee0d1c94ca99de941f78c7fa077c
js/app.c9ca98b5.js,1688152134604,0aebde1346f8555b4aa088782843dd0fb910532e0a132bcabbda043326553d8d
js/596.490767ac.js.map,1688152134620,58562c696fb13f9a14b6fb75aadeb909b46b344a3963db90fe5ab1bb937d4161
js/965.d0f02cb2.js.map,1688152134620,778d57f72e72840cfb5d57d2e5ac4757c63eef9c445159e57631a27c6496abdd
img/icons/android-chrome-maskable-512x512.png,1688152134605,e83b49eb1537fcb5016aa3a8b596566c1dc2e68a135c528c7c6a5076e528e95d
img/icons/android-chrome-512x512.png,1688152134605,07426bba3be5f2ea36f5a6f543b71bfb02277982e28e22509fd85f4f998aefff
js/756.0eb0c08f.js.map,1688152134620,325c91a3116dba58741ef3eac49665dcda0868a166ad54c6f762b7f2b56083ed
js/app.c9ca98b5.js.map,1688152134620,cdbcffe6c4db9ffd78f24b474b00195004827a13e756d18e0f56b90966a79aef
workbox-5b385ed2.js.map,1688152134620,a86fb2aa99509ea056c1a3a31828fc6cd2fbc971b9cb187b166c97407f3d68b5
css/app.6ddaf1bd.css,1688152134604,0f7af80f083e1d69f06f0fcc18032c9b273d0dc029299ccf333a30f5c6144e06
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.13749f83.woff2,1688152134604,415319a65ebbae03794f677a46ceba9420002ec35b0f196f225c94d3b9298d1e
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.4ad034d2.woff,1688152134604,f1274ddc3e217e312a25e9fd30e95bd7b448cde3d26f74b9313efa47826cf5c4
js/5.8b6e5d16.js.map,1688152134620,66c845379d03dd73fb1b3eea8170c3be3a11c9678e8323f6434143ace7c08d02
js/chunk-vendors.371caf34.js,1688152134604,71df44c193aff7c90ccdb27971a3811c670ceccad352b90f6a7b543372b11cb6
js/chunk-vendors.371caf34.js.map,1688152134621,b14712f41cb87d87f67f74792f06571611a33ddaf955009dd6dfcfcc590a5892
favicon.svg,1688494960154,f0b09d009aefe2b728c79ca5c6b284efc6e23cbb675d86f12d4bc5ddf245274e
manifest.json,1688494960153,91eaecfadc95cc9683074360cd9c6a8da54c20b945ba63a7aee98eb8043bdcd6
index.html,1688494960172,3ededcda333cb03ccb074069d84ca57c19c9c68a01db5017a5538a63423f5fee
service-worker.js,1688494960173,dfe23b3877f8d7ac56139f51b69b51ee2bd77d1c2643d497c10151753b33058e
robots.txt,1688494960155,c17e70846d7031bb27102edfb33b59d1e3e40a8e8e8097af75b7766e7fffc250
service-worker.js.map,1688494960172,6122cb7779f7fa61f2e29880cf3c02226cfc4438d1d1d541dd68eb3b5247a0a0
css/596.49a88333.css,1688494960154,a931f984ea4a02befb56e03f18ff0676dab99860f03134ce58530b74fe0fd51f
css/965.ac1019fb.css,1688494960154,71f2ba508395409211d507e41d547c272cad20706385f02ad5b9ae3c76e17e4d
favicon.ico,1688494960153,1e71457865f706dc865b49a54a86e193818220d290b30226b6630a42faf1535d
img/google-icon.c43e43a7.svg,1688494960154,4f74694f3fe10f89ab27082b1e6deae549279eb8f2c6e239063078e82860e060
workbox-5b385ed2.js,1688494960173,f66c7dd07974e2f6cd0044dd11b895814d60705007cb8e0d6e3fc74b8ebdbef8
img/icons/android-chrome-192x192.png,1688494960157,97e1127ad8db90e0349c838ecf9351fc0c370f9606f6ab309fe17444d26a9d59
img/icons/android-chrome-maskable-192x192.png,1688494960156,13d1c57561a4e596cc6b6eac9dcc101241daa58e3788850099d293a5cc5f6e80
img/icons/apple-touch-icon-120x120.png,1688494960156,13e4908bb32e2ca95e375ca720887ef85057fb3872d6f028c63ba22df9b12ed9
img/icons/apple-touch-icon-152x152.png,1688494960156,879d14ef1bd94f81c11ca6fa51ebca226bf6c88c86447aaf560752528e144067
img/icons/apple-touch-icon-180x180.png,1688494960156,ca5a8e637d730848e77716ed970da1a4a5fe9d3b4be21e43f33cf5ebcaf03e7d
img/icons/apple-touch-icon-60x60.png,1688494960156,a27014cb4410df491f64e3b5411987418ff6d729b351056a3de84e744c681a52
img/icons/apple-touch-icon-76x76.png,1688494960157,65d6c498ad60f94b338df3f1f4551303ec84306ecb1c7e615ed64489fffc8b28
img/icons/favicon-16x16.png,1688494960156,563096b119e9b3f8060292a6fc3e091e2a98ee0d1c94ca99de941f78c7fa077c
img/icons/apple-touch-icon.png,1688494960157,08b37da608cf827a037d8f600a01a32b2f74728291e679b03679fd3619da3a43
img/icons/favicon.svg,1688494960157,f0b09d009aefe2b728c79ca5c6b284efc6e23cbb675d86f12d4bc5ddf245274e
img/icons/favicon-32x32.png,1688494960156,f5a182df55d21b93c27ec89bd600abe40f3fac23df563e4cfc9efd5edd248886
img/icons/msapplication-icon-144x144.png,1688494960157,27b3b62de2e36ac452e86079762d3cfd37c33dc8cbde0a7c5657e5a7c32d971a
img/icons/safari-pinned-tab.svg,1688494960172,b96c516490acd2efe112a91da5af4fcb45188808bb3a22c4f05acbe781b2b2b2
img/icons/mstile-150x150.png,1688494960157,ea1dc2c1c63ffe2668cacc9d170cee33b50a2d58e1591b8399004629e3c1ae67
js/5.8b6e5d16.js,1688494960154,a7ad8a64d6de9681c71964f0c4b5da7b9f954b46b7d6a454a4bf08a22afda4d9
js/596.490767ac.js,1688494960154,57946407774c34ef89600ac3707f49ddccc4422dbd082c44bb2b92d70c170f78
js/756.0eb0c08f.js,1688494960154,acccb21381f634497ed4a6cbae090f0dda72325b6c95e53fac33484d226c0a01
js/965.d0f02cb2.js,1688494960154,a25885aad8f08bcfd3ddc9d67290b109c87cd63cb0381e27a07cac67dca6fab8
js/596.490767ac.js.map,1688494960172,58562c696fb13f9a14b6fb75aadeb909b46b344a3963db90fe5ab1bb937d4161
js/app.a7660d31.js,1688494960154,c469d81c4783a25d0a370efc7490f86a8a37a69d7ccb8d933de39f21fe0b30c5
js/965.d0f02cb2.js.map,1688494960172,778d57f72e72840cfb5d57d2e5ac4757c63eef9c445159e57631a27c6496abdd
img/icons/android-chrome-512x512.png,1688494960156,07426bba3be5f2ea36f5a6f543b71bfb02277982e28e22509fd85f4f998aefff
img/icons/android-chrome-maskable-512x512.png,1688494960156,e83b49eb1537fcb5016aa3a8b596566c1dc2e68a135c528c7c6a5076e528e95d
js/756.0eb0c08f.js.map,1688494960172,325c91a3116dba58741ef3eac49665dcda0868a166ad54c6f762b7f2b56083ed
js/app.a7660d31.js.map,1688494960173,a98c6b6f57bc13612a81286b24c41ec23fc2944ef9f30af7f4cdbe81e5fa451e
css/app.6ddaf1bd.css,1688494960154,0f7af80f083e1d69f06f0fcc18032c9b273d0dc029299ccf333a30f5c6144e06
workbox-5b385ed2.js.map,1688494960173,a86fb2aa99509ea056c1a3a31828fc6cd2fbc971b9cb187b166c97407f3d68b5
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.13749f83.woff2,1688494960154,415319a65ebbae03794f677a46ceba9420002ec35b0f196f225c94d3b9298d1e
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.4ad034d2.woff,1688494960154,f1274ddc3e217e312a25e9fd30e95bd7b448cde3d26f74b9313efa47826cf5c4
js/5.8b6e5d16.js.map,1688494960173,66c845379d03dd73fb1b3eea8170c3be3a11c9678e8323f6434143ace7c08d02
js/chunk-vendors.371caf34.js,1688494960154,71df44c193aff7c90ccdb27971a3811c670ceccad352b90f6a7b543372b11cb6
js/chunk-vendors.371caf34.js.map,1688494960173,b14712f41cb87d87f67f74792f06571611a33ddaf955009dd6dfcfcc590a5892
25 changes: 13 additions & 12 deletions src/components/AddingCardDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,19 @@ const speechRecognitionIsSupported = computed(() => {
return isSupported.value && !appStore.isPwa && !appStore.isMobileDevice // isPwa, isMobileDevice because of nowadays iOS PWA don't support permissions allow
})
const rules = computed(() => {
return { word: [(val) => !cardsStore.cards.find((card) => card.word?.toLowerCase() === val?.toLowerCase()) || 'Word already exists'] }
return {
word: [
(val) => {
const isExistWord = cardsStore.cards.find((card) => card.word?.toLowerCase() === val?.toLowerCase())
const isTheSameWord = form.value.word?.toLowerCase() === val?.toLowerCase()
return (isEditMode.value ? (!isExistWord || isTheSameWord) : !isExistWord) || 'Word already exists'
}
]
}
})
const isEditMode = computed(() => !!props.card && Object.keys(props.card).length)
const isSaveDisabled = computed(() => {
if (!props.card) return false
if (!isEditMode.value) return false
const { word, translate, example } = props.card
const initCard = { word, translate, example }
return JSON.stringify(form.value).split('').sort().join() === JSON.stringify(initCard).split('').sort().join()
Expand All @@ -185,7 +194,7 @@ watch(speechResult, (result) => {
})
onMounted(() => {
if (props.card) {
if (isEditMode.value) {
const { word, translate, example } = props.card
form.value = { word, translate, example }
}
Expand All @@ -211,15 +220,7 @@ const copyWordValue = () => {
}
const onSubmit = async () => {
if (cardsStore.cards.find((card) => card.word.toLowerCase() === form.value.word.toLowerCase())) {
$q.notify({
message: 'Card already exists',
color: 'error',
position: 'top'
})
return
}
if (props.card?.id) await cardsStore.updateCard(props.card.id, form.value)
if (isEditMode.value) await cardsStore.updateCard(props.card.id, form.value)
else await cardsStore.addNewWord(form.value)
onDialogHide()
}
Expand Down
26 changes: 19 additions & 7 deletions src/components/Cards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
size="32px"
@click.stop="toVisible"
/>
<span :class="{ blur: isBlurCard }">
<span :class="{ blur: isBlurCard && !cardIsExistInSecondStep(getCurrentCard.id) }">
{{
isFirstShow
? getCurrentCard?.[cardIsExistInSecondStep(getCurrentCard.id) ? 'word' : 'translate'] ?? 'Empty'
Expand Down Expand Up @@ -171,7 +171,6 @@ const learnCards = computed(() => {
const secondStepCardsStack = cardsStore.getToLearnCards.filter((card) => secondStepCardsIds.value.includes(card.id))
const lastShuffleCards = shuffleArray([...refreshCardsStack, ...secondStepCardsStack])
// return [...mainCardsStack, ...refreshCardsStack, ...secondStepCardsStack]
return [...mainCardsStack, ...lastShuffleCards]
})
const getCurrentCard = computed(() => {
Expand All @@ -180,11 +179,24 @@ const getCurrentCard = computed(() => {
})
watch(learnCards, (nv) => {
if (!nv.length) tabsStore.setTab('Home')
if (!nv.length) {
delete localStorage.processedCards
tabsStore.setTab('Home')
} else {
localStorage.processedCards = JSON.stringify({
refreshCardsIds: refreshCardsIds.value,
secondStepCardsIds: secondStepCardsIds.value
})
}
})
onMounted(() => {
speakStore.speak(getCurrentCard.value?.word)
if (localStorage.processedCards) {
const { refreshCardsIds: refreshLS, secondStepCardsIds: secondStepLS } = JSON.parse(localStorage.processedCards)
refreshCardsIds.value = refreshLS
secondStepCardsIds.value = secondStepLS
}
if (!cardIsExistInSecondStep(getCurrentCard.value?.id)) speakStore.speak(getCurrentCard.value?.word)
})
const toVisible = () => {
Expand Down Expand Up @@ -228,10 +240,10 @@ const refreshCard = async ({ reset }) => {
const { id: refreshCardId, level: refreshCardLvl } = getCurrentCard.value
if (!cardIsExistInRefreshCards(refreshCardId)) {
if (!cardIsExistInSecondStep(refreshCardId)) {
// if (!cardIsExistInSecondStep(refreshCardId)) {
const level = refreshCardLvl > 1 ? refreshCardLvl - 1 : 1
await cardsStore.updateCard(refreshCardId, { level })
}
// } //until test on my own
secondStepCardsIds.value = secondStepCardsIds.value.filter((id) => id !== refreshCardId)
refreshCardsIds.value.push(refreshCardId)
Expand All @@ -247,9 +259,9 @@ const refreshCard = async ({ reset }) => {
}
const cardClickHandler = () => {
if (cardIsExistInSecondStep(getCurrentCard.value.id) && !isFirstShow.value) speakStore.speak(getCurrentCard.value?.word)
visibleState.value = true
isFirstShow.value ||= true
if (cardIsExistInSecondStep(getCurrentCard.value.id)) speakStore.speak(getCurrentCard.value?.word)
}
const cardIsExistInSecondStep = (id) => secondStepCardsIds.value.includes(id)
Expand Down
23 changes: 13 additions & 10 deletions src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
class="q-ml-lg"
color="primary"
icon="add"
@click="cardsStore.showAddingCardDialog"
@click="cardsStore.showAddingCardDialog()"
/>
</div>
<transition-group name="scale">
Expand Down Expand Up @@ -243,20 +243,23 @@ const shownCardsList = ref([]) // TODO
const cardsList = computed(() => {
const { value: state } = cardState.value
if (!state) return searchValue.value ? cardsStore.getCards.filter((card) => card.word.toLowerCase().includes(searchValue.value.toLowerCase())) : cardsStore.getCards
if (!state)
return searchValue.value
? cardsStore.getCards.filter(
(card) => card.word.toLowerCase().includes(searchValue.value.toLowerCase()) || card.translate.toLowerCase().includes(searchValue.value.toLowerCase())
)
: cardsStore.getCards
// TODO improve performance
return searchValue.value ? cardsStore[state].filter((card) => card.word.toLowerCase().includes(searchValue.value.toLowerCase())) : cardsStore[state]
})
const isNotToLearnCard = (card) => !cardsStore.getToLearnCards.find((cardToLearn) => cardToLearn.id === card.id)
const toSearchCard = (value) => { // try to change to useDebounce
const toSearchCard = (value) => {
// try to change to useDebounce
clearTimeout(timeout.value)
timeout.value = setTimeout(() => {
if (!searchValue.value || searchValue.value.length >= 3) {
searchValue.value = value
} else {
searchValue.value = ''
}
searchValue.value = value
}, 600)
}
const openParticularCards = (widget) => {
Expand Down Expand Up @@ -284,11 +287,11 @@ const getReturnDate = (card) => {
return `${days}:${prepareTime(hours)}:${prepareTime(minutes)}`
}
const onLoadCards = (index, done) => { // TODO
const onLoadCards = (index, done) => {
// TODO
const shownLength = shownCardsList.value.length
if (shownLength >= cardsList.value.length) return
setTimeout(() => {
const newPartOfCards = cardsList.value.slice(shownLength, shownLength + 10)
shownCardsList.value.push(...newPartOfCards)
done()
Expand Down
30 changes: 26 additions & 4 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
</q-item-section>
</q-item>
</div>
<q-option-group
v-model="speakStore.currentLanguage"
class="flex justify-center"
:options="languages"
color="primary"
inline
/>
<q-select
v-model="speakStore.currentVoice"
rounded
Expand Down Expand Up @@ -80,7 +87,7 @@
/>
</div> -->
<q-input
v-model="text"
v-model="initText"
outlined
bg-color="white"
class="q-mt-md"
Expand All @@ -93,7 +100,7 @@
size="xl"
color="green"
icon="play_arrow"
@click="speakStore.speak(text)"
@click="speakStore.speak(initText)"
/>
<q-btn
round
Expand All @@ -117,12 +124,28 @@
import { useSpeakStore } from '@/store/speak'
import { useAuthStore } from '@/store/auth'
import { useQuasar } from 'quasar'
import { computed } from 'vue'
const speakStore = useSpeakStore()
const authStore = useAuthStore()
const $q = useQuasar()
const text = "This text is for checking the current speaker's voice"
const initText = computed(() => initialTexts[speakStore.currentLanguage] )
const languages = [
{
label: 'English',
value: 'en'
},
{
label: 'Italian',
value: 'it'
}
]
const initialTexts = {
en: "This text is for checking the current speaker's voice",
it: "Questo testo serve per controllare la voce dell'attuale oratore"
}
const logout = () => {
$q.dialog({
Expand All @@ -137,5 +160,4 @@ const logout = () => {
.onCancel(() => {})
.onDismiss(() => {})
}
</script>
Loading

0 comments on commit 2d128f6

Please sign in to comment.