@@ -23,20 +23,44 @@ const debug = makeDebugger('L:UserPublished')
23
23
24
24
let store = null
25
25
26
- export const loadPosts = ( page = 1 ) => {
27
- const args = {
26
+ const beforeQuery = page => {
27
+ store . markState ( { curView :TYPE . LOADING } )
28
+ // args
29
+ return {
28
30
userId :store . viewingUser . id ,
29
31
filter :pagedFilter ( page ) ,
30
32
}
31
-
32
- store . markState ( { curView :TYPE . LOADING } )
33
+ }
34
+ export const loadPosts = ( page = 1 ) => {
35
+ const args = beforeQuery ( page )
33
36
sr71$ . query ( S . publishedPosts , args )
34
37
}
35
38
36
- export function onPageChange ( page ) {
39
+ export const loadJobs = ( page = 1 ) => {
40
+ const args = beforeQuery ( page )
41
+ sr71$ . query ( S . publishedJobs , args )
42
+ }
43
+
44
+ export const loadVideos = ( page = 1 ) => {
45
+ const args = beforeQuery ( page )
46
+ sr71$ . query ( S . publishedVideos , args )
47
+ }
48
+
49
+ export const loadRepos = ( page = 1 ) => {
50
+ const args = beforeQuery ( page )
51
+ sr71$ . query ( S . publishedRepos , args )
52
+ }
53
+
54
+ export function reload ( page ) {
37
55
switch ( store . curThread ) {
38
56
case THREAD . JOB :{
39
- return debug ( 'load job' )
57
+ return loadJobs ( page )
58
+ }
59
+ case THREAD . VIDEO :{
60
+ return loadVideos ( page )
61
+ }
62
+ case THREAD . REPO :{
63
+ return loadRepos ( page )
40
64
}
41
65
default :{
42
66
return loadPosts ( page )
@@ -47,6 +71,7 @@ export function onPageChange(page) {
47
71
export function onThreadChange ( curThread ) {
48
72
// TODO: markRoute
49
73
store . markState ( { curThread} )
74
+ reload ( )
50
75
}
51
76
52
77
// ###############################
@@ -56,13 +81,19 @@ export function onThreadChange(curThread) {
56
81
const DataSolver = [
57
82
{
58
83
match :asyncRes ( 'publishedPosts' ) ,
59
- action :( { publishedPosts :pagedPosts } ) => {
60
- let curView = TYPE . RESULT
61
- if ( pagedPosts . entries . length === 0 ) {
62
- curView = TYPE . RESULT_EMPTY
63
- }
64
- store . markState ( { curView, pagedPosts} )
65
- } ,
84
+ action :( { publishedPosts} ) => store . markPagedData ( publishedPosts ) ,
85
+ } ,
86
+ {
87
+ match :asyncRes ( 'publishedJobs' ) ,
88
+ action :( { publishedJobs} ) => store . markPagedData ( publishedJobs ) ,
89
+ } ,
90
+ {
91
+ match :asyncRes ( 'publishedVideos' ) ,
92
+ action :( { publishedVideos} ) => store . markPagedData ( publishedVideos ) ,
93
+ } ,
94
+ {
95
+ match :asyncRes ( 'publishedRepos' ) ,
96
+ action :( { publishedRepos} ) => store . markPagedData ( publishedRepos ) ,
66
97
} ,
67
98
]
68
99
const ErrSolver = [