Skip to content

Commit

Permalink
fix: debug fav feature + some stories doesnt work
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyri1 committed Feb 20, 2023
1 parent 368e714 commit c102a8b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
9 changes: 8 additions & 1 deletion src/composables/handleSlideClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ export function detectTypeOfStageNode(actionNode) {
actionNode.controlSettings.ok === true &&
actionNode.controlSettings.pause === false &&
actionNode.controlSettings.wheel === false &&
actionNode.image !== null) ||
(actionNode.audio !== null && // test purpose
actionNode.controlSettings.autoplay === false &&
actionNode.controlSettings.home === true &&
actionNode.controlSettings.ok === true &&
actionNode.controlSettings.pause === false &&
actionNode.controlSettings.wheel === false &&
actionNode.image !== null)
) {
return { type: 'displaySlideSet', okTransition: actionNode.okTransition };
Expand All @@ -81,7 +88,7 @@ export function detectTypeOfStageNode(actionNode) {
actionNode.controlSettings.pause === false &&
actionNode.controlSettings.wheel === true &&
actionNode.image === null)
) {
) {
return { type: 'endOfStory', okTransition: null };
} else if (
(actionNode.audio !== null &&
Expand Down
6 changes: 5 additions & 1 deletion src/data/storiesIndex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
import { useStoryStore } from '../stores/StoryStores';

export async function storiesIndex() {
const storyStore = useStoryStore();
const directory = Directory.Documents;
var jsonStories = [];
var errors = [];
Expand Down Expand Up @@ -71,7 +73,9 @@ export async function storiesIndex() {
try {
var jsonStory = await JSON.parse(readStoryJson.data);
jsonStory['name'] = storyDir.name;
jsonStories.push(jsonStory);
if(!storyStore.unfavoriteStories.includes(storyDir.name)) { // remove unfav
jsonStories.push(jsonStory);
}
} catch (err) {
errors.push(
'Le fichier story.json de l\'histoire "' +
Expand Down
7 changes: 0 additions & 7 deletions src/stores/StoryStores.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,7 @@ export const useStoryStore = defineStore('StoryStore', {
}
});
Preferences.get({ key: 'unfavoriteStories' }).then((result) => {
if (result.value === null) {
Preferences.set({
key: 'unfavoriteStories',
value: JSON.stringify([]),
})
} else {
this.unfavoriteStories = JSON.parse(result.value)
}
});
},
async loadUnofficialStoreData() {
Expand Down
27 changes: 19 additions & 8 deletions src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@
</AudioRange>
</ion-col>
<ion-col size="2">
<ion-button class="preferences" :color="storyStore.theme + 'sec'" icon-only
@click="() => router.push('/preferences/tab1')" size="small">
<ion-button class="preferences" :color="storyStore.theme + 'sec'" icon-only @click="prefButton" size="small">
<ion-icon :icon="settingsOutline" size="small"></ion-icon>
</ion-button>
</ion-col>
</ion-row>
<ion-row class="ion-align-items-center middle-row">
<ion-col class="ion-align-items-center ion-text-center" size="2">
<ion-button class="big-buttons" :color="storyStore.theme + 'sec'" @click="homeButton" icon-only
size="large">
<ion-button class="big-buttons" :color="storyStore.theme + 'sec'" @click="homeButton" icon-only size="large">
<ion-icon :icon="home" size="large"></ion-icon>
</ion-button>
<button @click="debug" v-show="false" color="primary">
log datas
</button>
</ion-col>
<ion-col size="8">
<swiper :loop="true" v-show="storyStore.slidesVisible" :modules="modules" :effect="'flip'"
@swiper="onSwiper" @realIndexChange="useReadAudioActiveSlide()">
<swiper :loop="true" v-show="storyStore.slidesVisible" :modules="modules" :effect="'flip'" @swiper="onSwiper"
@realIndexChange="useReadAudioActiveSlide()">
<swiper-slide v-for="(slide, index) in storyStore.activeSlides" :key="index">
<ion-img @click="storeActiveStoryIndex(index), handleSlideClick(slide.okTransition)"
:src="useConvertPath(slide.name + '/assets/' + slide.image)">
Expand All @@ -35,8 +33,7 @@
</swiper>
</ion-col>
<ion-col size="2">
<ion-button @click="pauseButton" class="big-buttons" :color="storyStore.theme + 'sec'" icon-only
size="large">
<ion-button @click="pauseButton" class="big-buttons" :color="storyStore.theme + 'sec'" icon-only size="large">
<ion-icon :icon="pauseSharp" size="large" v-show="!storyStore.howlerIsPlaying"></ion-icon>
<ion-icon :icon="playOutline" size="large" v-show="storyStore.howlerIsPlaying"></ion-icon>
</ion-button>
Expand Down Expand Up @@ -123,6 +120,7 @@ onMounted(() => {
router.afterEach((to) => {
if (to.name === 'Home') {
storyStore.fillStoriesIndex()
homeButton()
}
})
Expand Down Expand Up @@ -166,6 +164,10 @@ function homeButton() {
}
}
function prefButton() {
router.push('/preferences/tab1')
}
function pauseButton() {
if (storyStore.storyAudioHowl.playing()) {
storyStore.storyAudioHowl.pause()
Expand All @@ -192,6 +194,15 @@ function handleSlideClick(okTransition) {
console.log('////HANDLING CLICK////')
if ((okTransition?.actionNode === oldOkTransition?.actionNode) && (okTransition?.optionIndex === oldOkTransition?.optionIndex)) {
console.log('preventing home button loop')
console.log('actionNode :')
console.log(okTransition?.actionNode)
console.log('old actionNode :')
console.log(oldOkTransition?.actionNode)
console.log('/*/*/*/*/*/*/*/*/*/*/*/*')
console.log('optionIndex :')
console.log(okTransition?.optionIndex)
console.log('old optionIndex :')
console.log(oldOkTransition?.optionIndex)
storyStore.homeTransition = null
homeButton()
return
Expand Down

0 comments on commit c102a8b

Please sign in to comment.