From ad1f0aa6622abf43c450898d11a1ced835bcb79f Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 31 May 2018 16:39:13 +0900
Subject: [PATCH] refs #355 Add tag search page and fetch initial timeline
---
.../TimelineSpace/Contents/Hashtag.vue | 54 +++++++++++++++++++
.../TimelineSpace/Contents/Hashtag/List.vue | 13 +++++
.../TimelineSpace/Contents/Hashtag/Tag.vue | 45 ++++++++++++++++
.../components/TimelineSpace/HeaderMenu.vue | 7 +++
.../components/TimelineSpace/SideMenu.vue | 4 ++
src/renderer/router/index.js | 20 ++++++-
src/renderer/store/TimelineSpace/Contents.js | 4 +-
.../store/TimelineSpace/Contents/Hashtag.js | 12 +++++
.../TimelineSpace/Contents/Hashtag/List.js | 5 ++
.../TimelineSpace/Contents/Hashtag/Tag.js | 32 +++++++++++
10 files changed, 194 insertions(+), 2 deletions(-)
create mode 100644 src/renderer/components/TimelineSpace/Contents/Hashtag.vue
create mode 100644 src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue
create mode 100644 src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
create mode 100644 src/renderer/store/TimelineSpace/Contents/Hashtag.js
create mode 100644 src/renderer/store/TimelineSpace/Contents/Hashtag/List.js
create mode 100644 src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.js
diff --git a/src/renderer/components/TimelineSpace/Contents/Hashtag.vue b/src/renderer/components/TimelineSpace/Contents/Hashtag.vue
new file mode 100644
index 00000000..0c230817
--- /dev/null
+++ b/src/renderer/components/TimelineSpace/Contents/Hashtag.vue
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue b/src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue
new file mode 100644
index 00000000..ab087db6
--- /dev/null
+++ b/src/renderer/components/TimelineSpace/Contents/Hashtag/List.vue
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
new file mode 100644
index 00000000..8a8dd392
--- /dev/null
+++ b/src/renderer/components/TimelineSpace/Contents/Hashtag/Tag.vue
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
diff --git a/src/renderer/components/TimelineSpace/HeaderMenu.vue b/src/renderer/components/TimelineSpace/HeaderMenu.vue
index 749e1d59..155630ba 100644
--- a/src/renderer/components/TimelineSpace/HeaderMenu.vue
+++ b/src/renderer/components/TimelineSpace/HeaderMenu.vue
@@ -45,6 +45,12 @@ export default {
case 'public':
this.$store.commit('TimelineSpace/HeaderMenu/updateTitle', 'Public timeline')
break
+ case 'hashtag-list':
+ this.$store.commit('TimelineSpace/HeaderMenu/updateTitle', 'Hashtag')
+ break
+ case 'tag':
+ this.$store.commit('TimelineSpace/HeaderMenu/updateTitle', this.$route.params.tag)
+ break
case 'search':
this.$store.commit('TimelineSpace/HeaderMenu/updateTitle', 'Search')
break
@@ -52,6 +58,7 @@ export default {
this.$store.dispatch('TimelineSpace/HeaderMenu/fetchList', this.$route.params.list_id)
break
default:
+ console.log(this.$route)
this.$store.commit('TimelineSpace/HeaderMenu/updateTitle', 'Home')
break
}
diff --git a/src/renderer/components/TimelineSpace/SideMenu.vue b/src/renderer/components/TimelineSpace/SideMenu.vue
index daad2a56..30d7168e 100644
--- a/src/renderer/components/TimelineSpace/SideMenu.vue
+++ b/src/renderer/components/TimelineSpace/SideMenu.vue
@@ -48,6 +48,10 @@
Public timeline
+
+
+ Hashtag
+
Search
diff --git a/src/renderer/router/index.js b/src/renderer/router/index.js
index fb8c44b5..97a6bf62 100644
--- a/src/renderer/router/index.js
+++ b/src/renderer/router/index.js
@@ -39,7 +39,7 @@ export default new Router({
children: [
{
path: ':id/',
- name: 'timeline-space/',
+ name: 'timeline-space',
component: require('@/components/TimelineSpace').default,
children: [
{
@@ -67,6 +67,24 @@ export default new Router({
name: 'public',
component: require('@/components/TimelineSpace/Contents/Public').default
},
+ {
+ path: 'hashtag/',
+ name: 'hashtag',
+ component: require('@/components/TimelineSpace/Contents/Hashtag').default,
+ children: [
+ {
+ path: '',
+ name: 'hashtag-list',
+ component: require('@/components/TimelineSpace/Contents/Hashtag/List').default
+ },
+ {
+ path: ':tag',
+ name: 'tag',
+ component: require('@/components/TimelineSpace/Contents/Hashtag/Tag').default,
+ props: true
+ }
+ ]
+ },
{
path: 'search',
name: 'search',
diff --git a/src/renderer/store/TimelineSpace/Contents.js b/src/renderer/store/TimelineSpace/Contents.js
index acb7387f..7c25e7a4 100644
--- a/src/renderer/store/TimelineSpace/Contents.js
+++ b/src/renderer/store/TimelineSpace/Contents.js
@@ -7,6 +7,7 @@ import Public from './Contents/Public'
import Search from './Contents/Search'
import Lists from './Contents/Lists'
import Cards from './Contents/Cards'
+import Hashtag from './Contents/Hashtag'
const Contents = {
namespaced: true,
@@ -19,7 +20,8 @@ const Contents = {
Public,
Search,
Lists,
- Cards
+ Cards,
+ Hashtag
}
}
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag.js b/src/renderer/store/TimelineSpace/Contents/Hashtag.js
new file mode 100644
index 00000000..5ebff18f
--- /dev/null
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag.js
@@ -0,0 +1,12 @@
+import List from './Hashtag/List'
+import Tag from './Hashtag/Tag'
+
+const Hashtag = {
+ namespaced: true,
+ modules: {
+ List,
+ Tag
+ }
+}
+
+export default Hashtag
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag/List.js b/src/renderer/store/TimelineSpace/Contents/Hashtag/List.js
new file mode 100644
index 00000000..36217f16
--- /dev/null
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag/List.js
@@ -0,0 +1,5 @@
+const List = {
+ namespaced: true
+}
+
+export default List
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.js b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.js
new file mode 100644
index 00000000..73e96f45
--- /dev/null
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.js
@@ -0,0 +1,32 @@
+import Mastodon from 'mastodon-api'
+
+const Tag = {
+ namespaced: true,
+ state: {
+ timeline: []
+ },
+ mutations: {
+ updateTimeline (state, timeline) {
+ state.timeline = timeline
+ }
+ },
+ actions: {
+ fetch ({ commit, rootState }, tag) {
+ return new Promise((resolve, reject) => {
+ const client = new Mastodon(
+ {
+ access_token: rootState.TimelineSpace.account.accessToken,
+ api_url: rootState.TimelineSpace.account.baseURL + '/api/v1'
+ }
+ )
+ client.get(`/timelines/tag/${tag}`, { limit: 40 }, (err, data, res) => {
+ if (err) return reject(err)
+ commit('updateTimeline', data)
+ resolve(res)
+ })
+ })
+ }
+ }
+}
+
+export default Tag