Skip to content

Commit

Permalink
Fix: When Saving flix revert back to draft
Browse files Browse the repository at this point in the history
  • Loading branch information
aabelmann committed Oct 31, 2024
1 parent 3cd9d16 commit 1007b03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Root .gitignore
.env

# Node.js
node_modules/
Expand Down
12 changes: 5 additions & 7 deletions nuxt/stores/flix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const useFlixStore = defineStore('flix', () => {
const currentFlix = ref<Flix>();
const currentToken = ref<string>();
const currentViewport = ref<PreviewMediaQuery>('laptop');
const isPreview = ref(false);
const isPreview = ref(true);

/**
* Computed Properties
Expand Down Expand Up @@ -39,7 +39,7 @@ export const useFlixStore = defineStore('flix', () => {
// Reset the values back to default
currentFlix.value = undefined;
currentToken.value = undefined;
isPreview.value = false;
isPreview.value = true;
currentViewport.value = 'laptop';

// Also clean up other stores
Expand Down Expand Up @@ -106,15 +106,13 @@ export const useFlixStore = defineStore('flix', () => {
}

// Check if we are publishing
if (publish) {
currentFlix.value.publishedAt = useStrapiDate();
currentFlix.value.status = 'published';
}
currentFlix.value.publishedAt = publish ? useStrapiDate() : null;
currentFlix.value.status = publish ? 'published' : 'draft';
isPreview.value = !publish;

// Save the flix
const response = await useSaveFlix(currentFlix.value);
if (response?.flix) {
isPreview.value = !!publish;
currentFlix.value = response.flix;
currentToken.value = response.hash;
return response.hash;
Expand Down

0 comments on commit 1007b03

Please sign in to comment.