فهرست منبع

Add totalPostsCount prop to scrubber from thread route

sbkwgh 8 سال پیش
والد
کامیت
e645e00c96
3فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 2 3
      src/components/PostScrubber.vue
  2. 1 1
      src/components/routes/Thread.vue
  3. 6 1
      src/store/modules/thread.js

+ 2 - 3
src/components/PostScrubber.vue

@@ -26,14 +26,13 @@
 <script>
 	export default {
 		name: 'PostScrubber',
+		props: ['posts'],
 		data () {
 			return {
 				clientY: 0,
 				lineTop: 0,
 				lineHeight: 0,
-				dragging: false,
-
-				posts: 20
+				dragging: false
 			}
 		},
 		computed: {

+ 1 - 1
src/components/routes/Thread.vue

@@ -1,6 +1,6 @@
 <template>
 	<div class='route_container'>
-		<post-scrubber></post-scrubber>
+		<post-scrubber :posts='$store.state.thread.totalPostsCount'></post-scrubber>
 		<header class='thread_header'>
 			<div
 				class='thread_header__thread_title thread_header__thread_title--app_header'

+ 6 - 1
src/store/modules/thread.js

@@ -17,7 +17,8 @@ const state = {
 	nextURL: '',
 	previousURL: '',
 	nextPostsCount: 10,
-	previousPostsCount: 0
+	previousPostsCount: 0,
+	totalPostsCount: 0
 }
 
 const getters = {
@@ -78,6 +79,7 @@ const actions = {
 				commit('setNextURL', res.data.meta.nextURL)
 				commit('setPreviousURL', res.data.meta.previousURL)
 				commit('setPostCounts', res.data.meta)
+				commit('setTotalPostsCount', res.data.postsCount)
 				commit('setPosts', res.data.Posts)
 
 				if(postNumber !== undefined) {
@@ -201,6 +203,9 @@ const mutations = {
 		state.previousPostsCount = meta.previousPostsCount
 		state.nextPostsCount = meta.nextPostsCount
 	},
+	setTotalPostsCount (state, count) {
+		state.totalPostsCount = count
+	},
 	incrementNextPostsCount (state) {
 		state.nextPostsCount++
 	},