Просмотр исходного кода

Update to use new api for pagination

sbkwgh 8 лет назад
Родитель
Сommit
108243d8c8
3 измененных файлов с 11 добавлено и 11 удалено
  1. 5 5
      src/components/routes/Thread.vue
  2. 1 1
      src/main.js
  3. 5 5
      src/store/modules/thread.js

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

@@ -35,7 +35,7 @@
 				<thread-post
 					v-for='(post, index) in posts'
 					@reply='replyUser'
-					@goToPost='$router.push({ params: { post_id: post.id } })'
+					@goToPost='$router.push({ params: { post_number: post.postNumber } })'
 					:post='post'
 					:show-reply='true'
 					:highlight='highlightedPostIndex === index'
@@ -128,15 +128,15 @@
 			loadInitialPosts () {
 				this.$store.dispatch('loadInitialPostsAsync', this)
 			},	
-			goToPost (id) {
-				this.$router.push({ params: { post_id: id } })
+			goToPost (number) {
+				this.$router.push({ params: { post_number: number } })
 				this.loadInitialPosts()
 			},
-			highlightPost (postId) {
+			highlightPost (postNumber) {
 				for(var i = 0; i < this.posts.length; i++) {
 					let post = this.posts[i]
 
-					if(post.id === postId) {
+					if(post.postNumber === postNumber) {
 						this.$nextTick(() => {
 							let postTop = this.$refs.posts[i].$el.getBoundingClientRect().top
 							let header = this.$refs.title.getBoundingClientRect().height

+ 1 - 1
src/main.js

@@ -36,7 +36,7 @@ const router = new VueRouter({
 		{ path: '/category/:category', component: Index },
 		{ path: '/start', component: Start },
 		{ path: '/thread/:slug/:id', component: Thread },
-		{ path: '/thread/:slug/:id/:post_id', component: Thread },
+		{ path: '/thread/:slug/:id/:post_number', component: Thread },
 		{ path: '/thread/new', component: ThreadNew },
 		{ path: '/user/:username', redirect: '/user/:username/posts', component: User, children: [
 			{ path: 'posts', component: UserPosts },

+ 5 - 5
src/store/modules/thread.js

@@ -52,11 +52,11 @@ const actions = {
 			.catch(AjaxErrorHandler(vue.$store))
 	},
 	loadInitialPostsAsync ({ state, commit, rootState }, vue) {
-		let postId = vue.$route.params.post_id
+		let postNumber = vue.$route.params.post_number
 		let apiURL = '/api/v1/thread/' + vue.$route.params.id
 
-		if(postId) {
-			apiURL += '?postId=' + postId
+		if(postNumber) {
+			apiURL += '?postNumber=' + postNumber
 		}
 
 		vue.axios
@@ -67,8 +67,8 @@ const actions = {
 				commit('setPreviousURL', res.data.meta.previousURL)
 				commit('setPosts', res.data.Posts)
 
-				if(postId) {
-					vue.highlightPost(+postId)
+				if(postNumber) {
+					vue.highlightPost(+postNumber)
 				}
 			}).catch(AjaxErrorHandler(vue.$store))
 	},