ソースを参照

Sort by time (newer -> older)

sbkwgh 8 年 前
コミット
c0507f920b
2 ファイル変更8 行追加2 行削除
  1. 1 1
      src/components/routes/Thread.vue
  2. 7 1
      src/store/modules/thread.js

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

@@ -67,7 +67,7 @@
 				return this.$store.state.thread.thread;
 			},
 			posts () {
-				return this.$store.state.thread.posts;
+				return this.$store.getters.sortedPosts;
 			},
 			replyUsername () {
 				return this.$store.state.thread.reply.username

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

@@ -13,7 +13,13 @@ const state = {
 	}
 }
 
-const getters = {}
+const getters = {
+	sortedPosts (state) {
+		return state.posts.sort((a, b) => {
+			return new Date(a.createdAt) - new Date(b.createdAt)
+		})
+	}
+}
 
 const actions = {
 	addPostAsync ({ state, commit, rootState }, vue) {