-
-
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!: rewrite vuex logic to set the source of truth the URL queries
BREAKING CHANGE: the source of truth is now the URL
- Loading branch information
1 parent
e11da2e
commit fd0e3fe
Showing
3 changed files
with
311 additions
and
120 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,54 @@ | ||
import { mapGetters, mapActions } from 'vuex' | ||
import { isEqual } from 'lodash-es' | ||
|
||
export default { | ||
computed: { | ||
...mapGetters('url', ['urlDomain', 'urlPage', 'urlTags']), | ||
}, | ||
|
||
watch: { | ||
async urlDomain(from, to) { | ||
if (from === to) { | ||
console.debug('Same domain, skipping...', [from, to]) | ||
return | ||
} | ||
|
||
console.debug('URL `domain` changed.', [from, to]) | ||
|
||
await this.fetchPosts() | ||
}, | ||
|
||
async urlPage(from, to) { | ||
if (from === to) { | ||
console.debug('Same page, skipping...', [from, to]) | ||
return | ||
} | ||
|
||
console.debug('URL `page` changed.', [from, to]) | ||
|
||
await this.fetchPosts() | ||
}, | ||
|
||
async urlTags(from, to) { | ||
if (isEqual(from, to)) { | ||
console.debug('Same tags, skipping...', [from, to]) | ||
return | ||
} | ||
|
||
console.debug('URL `tags` changed.', [from, to]) | ||
|
||
await this.fetchPosts() | ||
}, | ||
}, | ||
|
||
async mounted() { | ||
await this.setInitialUrlState() | ||
|
||
await this.fetchPosts() | ||
}, | ||
|
||
methods: { | ||
...mapActions('url', ['setInitialUrlState']), | ||
...mapActions('booru', ['fetchPosts']), | ||
}, | ||
} |
Oops, something went wrong.