From d98d6dd9069110edf0448061006e9d7e1016cb40 Mon Sep 17 00:00:00 2001 From: Cyri1 Date: Tue, 21 Feb 2023 17:00:05 +0100 Subject: [PATCH] feat: adding sleep mode feature --- src/composables/listStoryNodes.js | 41 ++++++++++++++++++++++++++++ src/stores/StoryStores.js | 10 ++----- src/views/HomePage.vue | 1 - src/views/PrefTab3.vue | 44 ++++++++++++++++++------------- 4 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 src/composables/listStoryNodes.js diff --git a/src/composables/listStoryNodes.js b/src/composables/listStoryNodes.js new file mode 100644 index 0000000..4f31f64 --- /dev/null +++ b/src/composables/listStoryNodes.js @@ -0,0 +1,41 @@ +import { useStoryStore } from '../stores/StoryStores'; +import { detectTypeOfStageNode } from './handleSlideClick'; + +export function useListStoryNodes() { + var nodeList = []; + const storyStore = useStoryStore(); + for (var story of storyStore.stories) { + for (var stageNode of story.stageNodes) { + if (stageNode.image) { + if (detectTypeOfStageNode(stageNode)?.type === 'displaySlideSet') { + var okTransition = detectTypeOfStageNode(stageNode)?.okTransition; + for (var actionNode of story.actionNodes) { + if (actionNode.id === okTransition.actionNode) { + var nextStageNodes = + actionNode.options[ + okTransition.optionIndex < 0 ? 0 : okTransition.optionIndex + ]; + for (var stageNodedisplaySlideSet of story.stageNodes) { + if (stageNodedisplaySlideSet.uuid === nextStageNodes) { + if ( + detectTypeOfStageNode(stageNodedisplaySlideSet)?.type === + 'audioStory' + ) { + stageNodedisplaySlideSet.name = story.name; + stageNodedisplaySlideSet.icon = stageNode.image; + nodeList.push(stageNodedisplaySlideSet); + } + } + } + } + } + } + } + } + } + var parsednodeList = []; + for (var node of nodeList) { + parsednodeList.push({'name': node.name, 'node': node}) + } + console.log(parsednodeList); +} \ No newline at end of file diff --git a/src/stores/StoryStores.js b/src/stores/StoryStores.js index 06a2949..d565165 100644 --- a/src/stores/StoryStores.js +++ b/src/stores/StoryStores.js @@ -10,6 +10,7 @@ export const useStoryStore = defineStore('StoryStore', { theme: null, contributorPwd: null, timelineVisible: null, + sleepModeModalIsOpen: false, unofficialStore: [], downloadedPacks: [], installedPacks: [], @@ -60,14 +61,7 @@ export const useStoryStore = defineStore('StoryStore', { } } } - //remove unfavorited stories from indexSlides - var indexSlidesWithoutUnfavorited = []; - for(let storySlide of indexSlides) { - if(!this.unfavoriteStories.includes(storySlide.name)) { - indexSlidesWithoutUnfavorited.push(storySlide); - } - } - this.activeSlides = indexSlidesWithoutUnfavorited; + this.activeSlides = indexSlides; }, setPreferences() { Preferences.get({ key: 'theme' }).then((result) => { diff --git a/src/views/HomePage.vue b/src/views/HomePage.vue index b468b83..9313271 100644 --- a/src/views/HomePage.vue +++ b/src/views/HomePage.vue @@ -120,7 +120,6 @@ onMounted(() => { router.afterEach((to) => { if (to.name === 'Home') { storyStore.fillStoriesIndex() - homeButton() } }) diff --git a/src/views/PrefTab3.vue b/src/views/PrefTab3.vue index a963f0f..dbfa8fd 100644 --- a/src/views/PrefTab3.vue +++ b/src/views/PrefTab3.vue @@ -20,7 +20,7 @@ - Activer le mode sommeil + Activer le mode sommeil @@ -37,23 +37,23 @@ - - - - Mode sommeil - - Fermer - - - - -

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni illum quidem recusandae ducimus quos - reprehenderit. Veniam, molestias quos, dolorum consequuntur nisi deserunt omnis id illo sit cum qui. Eaque, - dicta. -

-
-
+ + + + Mode sommeil + + Fermer + + + + +

+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni illum quidem recusandae ducimus quos + reprehenderit. Veniam, molestias quos, dolorum consequuntur nisi deserunt omnis id illo sit cum qui. Eaque, + dicta. +

+
+
@@ -83,6 +83,8 @@ import { import { onMounted } from "vue"; import { Preferences } from '@capacitor/preferences'; import { useStoryStore } from '../stores/StoryStores'; +import { useListStoryNodes } from '../composables/listStoryNodes'; + const storyStore = useStoryStore(); onMounted(() => { @@ -112,7 +114,7 @@ function changeContributorPwd(event) { } -function activeTimeline(event) { +function activeTimeline(event) { Preferences.set({ key: 'timelineVisible', value: String(event.detail.checked), @@ -120,5 +122,9 @@ function activeTimeline(event) { storyStore.timelineVisible = event.detail.checked } +function setOpen(isOpen) { + storyStore.sleepModeModalIsOpen = isOpen; + console.log(useListStoryNodes()); +} \ No newline at end of file