Skip to content

Commit

Permalink
feat(library): #275 show unpublished verses
Browse files Browse the repository at this point in the history
  • Loading branch information
akdasa committed Jun 11, 2023
1 parent 8e685c4 commit e46eb61
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"lint": "eslint"
},
"dependencies": {
"@akdasa-studios/shlokas-core": "1.1.19",
"@akdasa-studios/shlokas-core": "1.2.5",
"@akdasa-studios/shlokas-protocol": "^0.0.6",
"@akdasa-studios/shlokas-uikit": "0.0.19",
"@awesome-cordova-plugins/core": "6.3.0",
Expand Down
10 changes: 10 additions & 0 deletions src/app/library/composables/useLoadLibraryIntoMemory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ export function useLoadLibraryIntoMemory(
synonyms
)

// Data structure migration workaround
// feel free to remove it later
if (verse?.publication?.publishedAt === undefined) {
v.publication.publish()
}

if (verse?.publication?.publishedAt) {
v.publication.publish()
}

await app.repositories.verses.save(v)
}
} finally {
Expand Down
5 changes: 4 additions & 1 deletion src/app/library/pages/LibraryPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ async function onSearchQueryChanged(value: string) {
// NOTE: assign filteredVerses AFTER verseStatuses are fetched
const languageCode = language.value
const verses = await app.library.findByContent(new Language(languageCode, languageCode), value)
const verses = await app.library.findByContent(value, {
lang: new Language(languageCode, languageCode),
unpublished: settings.showUnpublishedVerses
})
verseStatuses.value = await app.library.getStatuses(verses.map(x => x.id))
filteredVerses.value = Array.from(verses).sort((a, b) => compareVerseNumber(a.number.value, b.number.value))
}
Expand Down
10 changes: 10 additions & 0 deletions src/app/settings/pages/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
</ion-toggle>
</ion-item>

<ion-item
v-if="isDevModeEnabled"
>
<ion-toggle
v-model="settings.showUnpublishedVerses"
>
{{ $t('settings.showUnpublishedVerses') }}
</ion-toggle>
</ion-item>

<ion-item>
<ion-label
@click="onSendEmail"
Expand Down
5 changes: 3 additions & 2 deletions src/app/settings/stores/useSettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const settingsKeys = [
'language', 'showGradeButtons', 'colorfulCards',
'welcomeDone', 'authToken', 'authSessionId', 'authStrategy',
'authRefreshedAt', 'authExpiresAt', 'syncCollectionId', 'syncAt',
'syncLibraryAt', 'reviewCardsInRandomOrder'
'syncLibraryAt', 'reviewCardsInRandomOrder', 'showUnpublishedVerses'
]


Expand All @@ -29,6 +29,7 @@ export const useSettingsStore = defineStore('settings', () => {
const authStrategy = ref('')
const authRefreshedAt = ref(0)
const authExpiresAt = ref(0)
const showUnpublishedVerses = ref(false)

// sync
const syncCollectionId = ref('')
Expand All @@ -46,6 +47,6 @@ export const useSettingsStore = defineStore('settings', () => {
return {
language, showGradeButtons, colorfulCards, syncLibraryAt, welcomeDone,
authToken, authSessionId, authStrategy, authRefreshedAt, authExpiresAt, syncCollectionId, syncAt,
showAccountControls, autoSyncOnLogin, reviewCardsInRandomOrder
showAccountControls, autoSyncOnLogin, reviewCardsInRandomOrder, showUnpublishedVerses
}
})
3 changes: 2 additions & 1 deletion src/locale/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"update": "Update",
"clearCache": "Clear cache",
"reviewCardsInRandomOrder": "Randomize review cards",
"cache": "Cache"
"cache": "Cache",
"showUnpublishedVerses": "Unpublished verses"
},
"account": {
"welcomeBack": "Welcome back!",
Expand Down
3 changes: 2 additions & 1 deletion src/locale/ru/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"update": "Обновить",
"clearCache": "Очистить кэш",
"reviewCardsInRandomOrder": "Обзор в случайном порядке",
"cache": "Кэш"
"cache": "Кэш",
"showUnpublishedVerses": "Неопубликованные стихи"
},
"account": {
"welcomeBack": "Добро пожаловать!",
Expand Down
3 changes: 2 additions & 1 deletion src/locale/uk/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"contactUs": "Зв'язатися з нами",
"update": "Update",
"reviewCardsInRandomOrder": "Випадковий порядок",
"cache": "Кеш"
"cache": "Кеш",
"showUnpublishedVerses": "Неопубліковані вірші"
},
"account": {
"welcomeBack": "З Поверненням!",
Expand Down

0 comments on commit e46eb61

Please sign in to comment.