Changed range filter to routes for every view.

This commit is contained in:
2020-05-09 01:10:07 +02:00
parent 525995615a
commit de5b729c0b
16 changed files with 125 additions and 73 deletions

View File

@@ -1,9 +1,12 @@
import { graphql } from '../api';
import { releasesFragment } from '../fragments';
import { curateSite } from '../curate';
import getDateRange from '../get-date-range';
function initSitesActions(store, _router) {
async function fetchSiteBySlug(siteSlug, limit = 100) {
async function fetchSiteBySlug({ _commit }, { siteSlug, limit = 100, range = 'latest' }) {
const { before, after, orderBy } = getDateRange(range);
const { site } = await graphql(`
query Site(
$siteSlug: String!,
@@ -36,21 +39,17 @@ function initSitesActions(store, _router) {
`, {
siteSlug,
limit,
after: store.getters.after,
before: store.getters.before,
after,
before,
orderBy,
isNew: store.getters.isNew,
orderBy: store.getters.orderBy,
exclude: store.state.ui.filter,
});
return curateSite(site);
}
async function fetchSites({ _commit }, { siteSlug, limit = 100 }) {
if (siteSlug) {
return fetchSiteBySlug(siteSlug, limit);
}
async function fetchSites({ _commit }, { limit = 100 }) {
const { sites } = await graphql(`
query Sites(
$actorSlug: String!
@@ -102,6 +101,7 @@ function initSitesActions(store, _router) {
}
return {
fetchSiteBySlug,
fetchSites,
searchSites,
};