forked from rrgayhart/webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscover.js
102 lines (93 loc) · 2.32 KB
/
discover.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React from 'react'
import * as ACTION_TYPES from '../constants/action_types'
import * as StreamRenderables from '../components/streams/StreamRenderables'
import navCategoriesQuery from '../queries/navCategories'
import allCategoriesQuery from '../queries/allCategories'
import { ZeroSubscribedStream } from '../components/zeros/Zeros'
import {
globalPostStreamQuery,
subscribedPostStreamQuery,
categoryPostStreamQuery,
} from '../queries/postStreamQueries'
import categoryDetailsQuery from '../queries/categoryDetailsQuery'
const KINDS = {
featured: 'FEATURED',
recent: 'RECENT',
trending: 'TRENDING',
shop: 'SHOP',
}
const postStreamMeta = {
renderStream: {
asList: StreamRenderables.postsAsList,
asGrid: StreamRenderables.postsAsGrid,
},
}
export function getCategories() {
return {
type: ACTION_TYPES.V3.LOAD_CATEGORIES,
payload: {
query: allCategoriesQuery,
variables: {},
},
}
}
export function getNavCategories() {
return {
type: ACTION_TYPES.V3.LOAD_CATEGORIES,
payload: {
query: navCategoriesQuery,
variables: {},
},
}
}
export function loadGlobalPostStream(kind, before) {
return {
type: ACTION_TYPES.V3.LOAD_STREAM,
payload: {
query: globalPostStreamQuery,
variables: { kind: KINDS[kind], before },
},
meta: postStreamMeta,
}
}
export function loadSubscribedPostStream(kind, before) {
return {
type: ACTION_TYPES.V3.LOAD_STREAM,
payload: {
query: subscribedPostStreamQuery,
variables: { kind: KINDS[kind], before },
},
meta: {
renderStream: {
asList: StreamRenderables.postsAsList,
asGrid: StreamRenderables.postsAsGrid,
asZero: <ZeroSubscribedStream />,
},
},
}
}
export function loadCategoryPostStream(slug, kind, before) {
return {
type: ACTION_TYPES.V3.LOAD_STREAM,
payload: {
query: categoryPostStreamQuery,
variables: { kind: KINDS[kind], slug, before },
},
meta: postStreamMeta,
}
}
export function loadCategoryDetails(slug) {
return {
type: ACTION_TYPES.V3.CATEGORY.LOAD,
payload: {
query: categoryDetailsQuery,
variables: { slug, roles: ['CURATOR', 'MODERATOR'] },
},
}
}
export function bindDiscoverKey(type) {
return {
type: ACTION_TYPES.GUI.BIND_DISCOVER_KEY,
payload: { type },
}
}