Explorar o código

Update threads on route change

sbkwgh %!s(int64=8) %!d(string=hai) anos
pai
achega
fa3f4feeb8
Modificáronse 1 ficheiros con 10 adicións e 7 borrados
  1. 10 7
      src/components/routes/Category.vue

+ 10 - 7
src/components/routes/Category.vue

@@ -113,6 +113,14 @@
 		methods: {
 			navigateToThread (slug, id) {
 				this.$router.push('/thread/' + slug + '/' + id);
+			},
+			getThreads () {
+				this.axios
+					.get('/api/v1/category/' + this.selectedCategory)
+					.then(res => {
+						this.threads = res.data.Threads
+					})
+					.catch(AjaxErrorHandler(this.$store))
 			}
 		},
 		watch: {
@@ -121,17 +129,12 @@
 			},
 			$route () {
 				this.selectedCategory = this.$route.path.split('/')[2].toUpperCase()
+				this.getThreads()
 			}
 		},
 		created () {
 			this.selectedCategory = this.$route.path.split('/')[2].toUpperCase()
-
-			this.axios
-				.get('/api/v1/category/' + this.selectedCategory)
-				.then(res => {
-					this.threads = res.data.Threads
-				})
-				.catch(AjaxErrorHandler(this.$store))
+			this.getThreads()
 		}
 	}
 </script>