-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create mixin for applying initial data on posts page load
BREAKING CHANGE: Replaces URLQueryManagerMixin for now as it didnt work correctly
- Loading branch information
1 parent
5f78b2e
commit 1eb0fe6
Showing
2 changed files
with
24 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { mapState, mapActions } from 'vuex' | ||
|
||
export default { | ||
mounted() { | ||
this.setInitialPageIDAndFetch() | ||
}, | ||
|
||
computed: { | ||
...mapState('booru', ['posts', 'queries']), | ||
}, | ||
|
||
methods: { | ||
...mapActions('booru', ['fetchPosts', 'pidManager']), | ||
|
||
async setInitialPageIDAndFetch() { | ||
if (this.queries.pid === undefined) | ||
await this.pidManager({ operation: 'reset' }) | ||
|
||
if (!this.posts.data.length) this.fetchPosts() | ||
}, | ||
}, | ||
} |
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