Skip to content

Commit

Permalink
add random factor and pretend user from the same card again + bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shestmintsev-kirill committed Jun 30, 2023
1 parent 67d8fc6 commit fc185c8
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 85 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,1687967271893,ce7f3051a6c502a0ec71e153090ecea334bde30d4f8cf70193fad5e86dd6e3c7
favicon.svg,1687967271874,f0b09d009aefe2b728c79ca5c6b284efc6e23cbb675d86f12d4bc5ddf245274e
manifest.json,1687967271874,91eaecfadc95cc9683074360cd9c6a8da54c20b945ba63a7aee98eb8043bdcd6
service-worker.js,1687967271894,e8cde6a01bf026b8f378901ee0ee9c7c1a4afade84ffe01e708698f4f2d5a819
favicon.ico,1687967271874,1e71457865f706dc865b49a54a86e193818220d290b30226b6630a42faf1535d
service-worker.js.map,1687967271893,64653dab2c5f1bc6304d259633f52a112f65e305d12de26158aec7755b647802
robots.txt,1687967271876,c17e70846d7031bb27102edfb33b59d1e3e40a8e8e8097af75b7766e7fffc250
css/430.98dc1a8d.css,1687967271876,69a78801ecc562a0e42a024de2699fd1902141b3e2d652a4c7e1e04646c98b2c
css/690.bedc8eaf.css,1687967271876,f48b957cdb3f302c8baff1d8cdbf6ed09c8c77e6298e817fde1f37896f243952
img/google-icon.c43e43a7.svg,1687967271875,4f74694f3fe10f89ab27082b1e6deae549279eb8f2c6e239063078e82860e060
workbox-5b385ed2.js,1687967271895,f66c7dd07974e2f6cd0044dd11b895814d60705007cb8e0d6e3fc74b8ebdbef8
img/icons/android-chrome-192x192.png,1687967271877,97e1127ad8db90e0349c838ecf9351fc0c370f9606f6ab309fe17444d26a9d59
img/icons/android-chrome-maskable-192x192.png,1687967271877,13d1c57561a4e596cc6b6eac9dcc101241daa58e3788850099d293a5cc5f6e80
img/icons/apple-touch-icon-120x120.png,1687967271877,13e4908bb32e2ca95e375ca720887ef85057fb3872d6f028c63ba22df9b12ed9
img/icons/apple-touch-icon-152x152.png,1687967271877,879d14ef1bd94f81c11ca6fa51ebca226bf6c88c86447aaf560752528e144067
img/icons/apple-touch-icon-180x180.png,1687967271877,ca5a8e637d730848e77716ed970da1a4a5fe9d3b4be21e43f33cf5ebcaf03e7d
img/icons/apple-touch-icon-60x60.png,1687967271877,a27014cb4410df491f64e3b5411987418ff6d729b351056a3de84e744c681a52
img/icons/apple-touch-icon-76x76.png,1687967271877,65d6c498ad60f94b338df3f1f4551303ec84306ecb1c7e615ed64489fffc8b28
img/icons/favicon-16x16.png,1687967271878,563096b119e9b3f8060292a6fc3e091e2a98ee0d1c94ca99de941f78c7fa077c
img/icons/apple-touch-icon.png,1687967271877,08b37da608cf827a037d8f600a01a32b2f74728291e679b03679fd3619da3a43
img/icons/favicon.svg,1687967271877,f0b09d009aefe2b728c79ca5c6b284efc6e23cbb675d86f12d4bc5ddf245274e
img/icons/favicon-32x32.png,1687967271877,f5a182df55d21b93c27ec89bd600abe40f3fac23df563e4cfc9efd5edd248886
img/icons/safari-pinned-tab.svg,1687967271892,b96c516490acd2efe112a91da5af4fcb45188808bb3a22c4f05acbe781b2b2b2
img/icons/msapplication-icon-144x144.png,1687967271877,27b3b62de2e36ac452e86079762d3cfd37c33dc8cbde0a7c5657e5a7c32d971a
img/icons/mstile-150x150.png,1687967271878,ea1dc2c1c63ffe2668cacc9d170cee33b50a2d58e1591b8399004629e3c1ae67
js/430.7538ac2c.js,1687967271875,87aaefae2bd114b0796929b7584bb94fe2d25b1dca1d976ced1a3a01b5b8dab4
js/5.8b6e5d16.js,1687967271875,a7ad8a64d6de9681c71964f0c4b5da7b9f954b46b7d6a454a4bf08a22afda4d9
js/690.f92ef411.js,1687967271876,039e50f04dd1331cb40ee2e53ef48127101222f41b67aa44bcc212f883cbfe30
js/430.7538ac2c.js.map,1687967271893,22dffa63e76748f7eb5c9c6b0edbeba9d5fa861502ebb586ed9960e2862e9011
js/690.f92ef411.js.map,1687967271894,3aa2fa523fdf890960e0be6276eade0eb3cf45b1118bdebf1d4af832baf08448
js/app.53a0fce0.js,1687967271876,dba41ec30952aecddb562a3d3b4107de64a13b918537a636546987c898364e09
js/756.0b57c535.js,1687967271875,c2bbf154a59281a36afd629c9c38ec8e148e260487526b1de2c9e761d10475fe
img/icons/android-chrome-512x512.png,1687967271877,07426bba3be5f2ea36f5a6f543b71bfb02277982e28e22509fd85f4f998aefff
img/icons/android-chrome-maskable-512x512.png,1687967271877,e83b49eb1537fcb5016aa3a8b596566c1dc2e68a135c528c7c6a5076e528e95d
js/756.0b57c535.js.map,1687967271893,fe83c1e89b479916f9623faaf8faec69c4994118b8d712cb7546957c5d17eb14
js/app.53a0fce0.js.map,1687967271893,6a7c9abebeb919d08bdf7885df635576e9c0f55b2c9f122c95ac06c1f0576f15
workbox-5b385ed2.js.map,1687967271895,a86fb2aa99509ea056c1a3a31828fc6cd2fbc971b9cb187b166c97407f3d68b5
css/app.337c5cfa.css,1687967271875,b94b8df4da1a379bab90e8d10e9bd739b7e373181d776afa9872abeffce27aec
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.13749f83.woff2,1687967271875,415319a65ebbae03794f677a46ceba9420002ec35b0f196f225c94d3b9298d1e
fonts/flUhRq6tzZclQEJ-Vdg-IuiaDsNa.4ad034d2.woff,1687967271875,f1274ddc3e217e312a25e9fd30e95bd7b448cde3d26f74b9313efa47826cf5c4
js/5.8b6e5d16.js.map,1687967271894,66c845379d03dd73fb1b3eea8170c3be3a11c9678e8323f6434143ace7c08d02
js/chunk-vendors.371caf34.js,1687967271875,71df44c193aff7c90ccdb27971a3811c670ceccad352b90f6a7b543372b11cb6
js/chunk-vendors.371caf34.js.map,1687967271894,b14712f41cb87d87f67f74792f06571611a33ddaf955009dd6dfcfcc590a5892
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
80 changes: 49 additions & 31 deletions src/components/Cards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@
class="my-card bg-grey-1 flex justify-center"
style="height: calc(100vh - 180px)"
@click="cardClickHandler"
@touchmove="cardClickHandler"
>
<q-card-section class="flex column items-center justify-center">
<div class="row items-center no-wrap">
<q-btn
v-if="!!getCurrentCard?.word && (cardIsExistInSecondStep ? isFirstShow : !isFirstShow)"
v-if="!!getCurrentCard?.word && (cardIsExistInSecondStep(getCurrentCard.id) ? isFirstShow : !isFirstShow)"
flat
round
@click.stop="speakStore.speak(getCurrentCard.word)"
Expand All @@ -61,7 +62,7 @@
</q-btn>
<div class="text-h6 relative-position text-center">
<q-icon
v-if="isBlurCard && !cardIsExistInSecondStep"
v-if="isBlurCard && !cardIsExistInSecondStep(getCurrentCard.id)"
class="absolute-center z-top"
name="visibility"
color="grey-7"
Expand All @@ -71,14 +72,14 @@
<span :class="{ blur: isBlurCard }">
{{
isFirstShow
? getCurrentCard?.[cardIsExistInSecondStep ? 'word' : 'translate'] ?? 'Empty'
: getCurrentCard?.[cardIsExistInSecondStep ? 'translate' : 'word'] ?? 'Empty'
? getCurrentCard?.[cardIsExistInSecondStep(getCurrentCard.id) ? 'word' : 'translate'] ?? 'Empty'
: getCurrentCard?.[cardIsExistInSecondStep(getCurrentCard.id) ? 'translate' : 'word'] ?? 'Empty'
}}
</span>
</div>
</div>
<div
v-if="!!getCurrentCard?.example && (cardIsExistInSecondStep ? isFirstShow : !isFirstShow)"
v-if="!!getCurrentCard?.example && (cardIsExistInSecondStep(getCurrentCard.id) ? isFirstShow : !isFirstShow)"
class="row q-mt-md items-center no-wrap"
>
<q-btn
Expand Down Expand Up @@ -155,27 +156,28 @@ const isEmptyCards = computed(() => {
const isBlurCard = computed(() => {
return !isFirstShow.value && getCurrentCard.value?.level > 3 && visibleState.value
})
const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
;[array[i], array[j]] = [array[j], array[i]]
}
return array
} // TODO вынести в helper
const learnCards = computed(() => {
const mainCardsStack = cardsStore.getToLearnCards.filter((card) => !refreshCardsIds.value.includes(card.id) && !secondStepCardsIds.value.includes(card.id))
const refreshCardsStack = cardsStore.getToLearnCards.filter((card) => refreshCardsIds.value.includes(card.id))
const secondStepCardsStack = cardsStore.getToLearnCards.filter((card) => secondStepCardsIds.value.includes(card.id))
const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = (Math.floor(Math.random() * (i + 1))[(array[i], array[j])] = [array[j], array[i]])
}
return array
} // TODO вынести в helper
const lastShuffleCards = shuffleArray([...refreshCardsStack, ...secondStepCardsStack])
// return [...mainCardsStack, ...refreshCardsStack, ...secondStepCardsStack]
return [...mainCardsStack, ...lastShuffleCards]
})
const getCurrentCard = computed(() => {
return learnCards.value[0]
// return cardsStore.getCurrentCard
})
const cardIsExistInSecondStep = computed(() => secondStepCardsIds.value.includes(getCurrentCard.value?.id))
const cardIsExistInRefreshCards = computed(() => refreshCardsIds.value.includes(getCurrentCard.value?.id))
watch(learnCards, (nv) => {
if (!nv.length) tabsStore.setTab('Home')
Expand All @@ -190,52 +192,68 @@ const toVisible = () => {
}
const completeCard = async ({ reset }) => {
const { cardInSecondStep } = setCardToSecondStep()
refreshCardsIds.value = refreshCardsIds.value.filter((id) => id !== getCurrentCard.value.id)
const { id: completeCardId, level: completeCardLvl } = getCurrentCard.value
const { cardInSecondStep } = setCardToSecondStep(completeCardId)
refreshCardsIds.value = refreshCardsIds.value.filter((id) => id !== completeCardId)
if (!cardInSecondStep) {
await cardsStore.updateCard(getCurrentCard.value.id, {
level: getCurrentCard.value.level + 1,
secondStepCardsIds.value = secondStepCardsIds.value.filter((id) => id !== completeCardId)
await cardsStore.updateCard(completeCardId, {
level: completeCardLvl + 1,
date: new Date().toISOString()
})
}
if (!learnCards.value.length) return
while(getCurrentCard.value?.id === secondStepCardsIds && secondStepCardsIds.value.length > 1) {
secondStepCardsIds.value = shuffleArray(secondStepCardsIds.value)
}
reset()
isFirstShow.value = false
if (!cardIsExistInSecondStep.value) speakStore.speak(getCurrentCard.value?.word)
if (!cardIsExistInSecondStep(getCurrentCard.value?.id)) speakStore.speak(getCurrentCard.value?.word)
}
const setCardToSecondStep = () => {
if (!cardIsExistInSecondStep.value) {
secondStepCardsIds.value.push(getCurrentCard.value.id)
const setCardToSecondStep = (cardId) => {
if (!cardIsExistInSecondStep(cardId)) {
secondStepCardsIds.value.push(cardId)
return { cardInSecondStep: true }
}
return { cardInSecondStep: false }
}
const refreshCard = async ({ reset }) => {
if (!cardIsExistInRefreshCards.value) {
const { id: refreshCardId, level: refreshCardLvl } = getCurrentCard.value
if (!cardIsExistInSecondStep.value) {
const { id, level: cardLvl } = getCurrentCard.value
const level = cardLvl > 1 ? cardLvl - 1 : 1
await cardsStore.updateCard(id, { level })
if (!cardIsExistInRefreshCards(refreshCardId)) {
if (!cardIsExistInSecondStep(refreshCardId)) {
const level = refreshCardLvl > 1 ? refreshCardLvl - 1 : 1
await cardsStore.updateCard(refreshCardId, { level })
}
secondStepCardsIds.value = secondStepCardsIds.value.filter((id) => id !== getCurrentCard.value.id)
refreshCardsIds.value.push(getCurrentCard.value.id)
secondStepCardsIds.value = secondStepCardsIds.value.filter((id) => id !== refreshCardId)
refreshCardsIds.value.push(refreshCardId)
}
while(getCurrentCard.value?.id === refreshCardId && refreshCardsIds.value.length > 1) {
refreshCardsIds.value = shuffleArray(refreshCardsIds.value)
}
reset()
isFirstShow.value = false
if (!cardIsExistInSecondStep.value) speakStore.speak(getCurrentCard.value?.word)
if (!cardIsExistInSecondStep(getCurrentCard.value?.id)) speakStore.speak(getCurrentCard.value?.word)
}
const cardClickHandler = () => {
visibleState.value = true
isFirstShow.value ||= true
if (cardIsExistInSecondStep.value) speakStore.speak(getCurrentCard.value?.word)
if (cardIsExistInSecondStep(getCurrentCard.value.id)) speakStore.speak(getCurrentCard.value?.word)
}
const cardIsExistInSecondStep = (id) => secondStepCardsIds.value.includes(id)
const cardIsExistInRefreshCards = (id) => refreshCardsIds.value.includes(id)
</script>
<style lang="scss" scoped>
Expand Down
11 changes: 0 additions & 11 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ import { firebaseApp } from './firebase'
import { VueFire, VueFireAuth } from 'vuefire'
import './styles/main.scss'

if (window.screen.orientation && window.screen.orientation.lock) {
window.screen.orientation
.lock('portrait')
.then(() => {
console.log('Screen orientation locked to portrait')
})
.catch((error) => {
console.error('Failed to lock screen orientation:', error)
})
} // TODO send to plugins/helpers

createApp(App)
.use(VueFire, {
firebaseApp,
Expand Down

0 comments on commit fc185c8

Please sign in to comment.