-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
863 additions
and
860 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Application, InboxCardMemorized, UpdateVerseStatus } from '@akdasa-studios/shlokas-core' | ||
import { useArrayFilter, useArrayFind } from '@vueuse/core' | ||
import { computed } from 'vue' | ||
import { InboxVerseCardViewModel, useInboxDeckStore } from '@/app/decks/inbox' | ||
import { useToast } from '@/app/composables' | ||
|
||
|
||
export function useInboxDeck(app: Application) { | ||
const inboxDeckStore = useInboxDeckStore() | ||
const cardMemorizedToast = useToast() | ||
const cardsToShow = useArrayFilter(inboxDeckStore.cards, x => x.index < 3) | ||
const topCard = useArrayFind(inboxDeckStore.cards, x => x.index === 0) | ||
const isEmpty = computed(() => inboxDeckStore.cards.length === 0) | ||
|
||
/** | ||
* Shifts the top card to the bottom of the deck. | ||
*/ | ||
function shiftTopCard() { | ||
inboxDeckStore.shiftTopCard() | ||
} | ||
|
||
/** | ||
* Removes the top card from the deck and marks it as memorized. | ||
*/ | ||
async function memorizeTopCard() { | ||
const cardViewModel = inboxDeckStore.removeTopCard() as InboxVerseCardViewModel | ||
if (cardViewModel) { | ||
const inboxCard = cardViewModel.card | ||
await app.processor.execute(new InboxCardMemorized(inboxCard)) | ||
await app.processor.execute(new UpdateVerseStatus(inboxCard.verseId)) | ||
cardMemorizedToast.open() | ||
} | ||
} | ||
|
||
/** | ||
* Reverts the last action. | ||
*/ | ||
async function revert() { | ||
await app.processor.revert() | ||
} | ||
|
||
return { | ||
cardsToShow, isEmpty, | ||
cardMemorizedToast, | ||
shiftTopCard, | ||
memorizeTopCard, | ||
revert, | ||
topCard, | ||
// addCardsToDeck | ||
} | ||
} |
Oops, something went wrong.