diff --git a/src/main/index.js b/src/main/index.js
index 461c5d1e..e2c54c97 100644
--- a/src/main/index.js
+++ b/src/main/index.js
@@ -291,6 +291,39 @@ ipcMain.on('stop-local-streaming', (event, _) => {
localStreaming = null
})
+let publicStreaming = null
+
+ipcMain.on('start-public-streaming', (event, ac) => {
+ const account = new Account(db)
+ account.getAccount(ac._id)
+ .catch((err) => {
+ event.sender.send('error-start-public-streaming', err)
+ })
+ .then((account) => {
+ // Stop old public streaming
+ if (publicStreaming !== null) {
+ publicStreaming.stop()
+ publicStreaming = null
+ }
+
+ publicStreaming = new Streaming(account)
+ publicStreaming.start(
+ '/streaming/public',
+ (update) => {
+ event.sender.send('update-start-public-streaming', update)
+ },
+ (err) => {
+ event.sender.send('error-start-public-streaming', err)
+ }
+ )
+ })
+})
+
+ipcMain.on('stop-public-streaming', (event, _) => {
+ publicStreaming.stop()
+ publicStreaming = null
+})
+
/**
* Auto Updater
*
diff --git a/src/renderer/components/TimelineSpace/Global.vue b/src/renderer/components/TimelineSpace/Global.vue
deleted file mode 100644
index b8c512a2..00000000
--- a/src/renderer/components/TimelineSpace/Global.vue
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
- global
-
-
-
-
diff --git a/src/renderer/components/TimelineSpace/Public.vue b/src/renderer/components/TimelineSpace/Public.vue
new file mode 100644
index 00000000..9b40dc80
--- /dev/null
+++ b/src/renderer/components/TimelineSpace/Public.vue
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
diff --git a/src/renderer/components/TimelineSpace/SideMenu.vue b/src/renderer/components/TimelineSpace/SideMenu.vue
index ce3c6e22..0f41ef54 100644
--- a/src/renderer/components/TimelineSpace/SideMenu.vue
+++ b/src/renderer/components/TimelineSpace/SideMenu.vue
@@ -29,7 +29,7 @@
LocalTimeline
-
+
PublicTimeline
diff --git a/src/renderer/router/index.js b/src/renderer/router/index.js
index febc5fd5..3c9ec88a 100644
--- a/src/renderer/router/index.js
+++ b/src/renderer/router/index.js
@@ -46,9 +46,9 @@ export default new Router({
component: require('@/components/TimelineSpace/Local').default
},
{
- path: 'global',
- name: 'global',
- component: require('@/components/TimelineSpace/Global').default
+ path: 'public',
+ name: 'public',
+ component: require('@/components/TimelineSpace/Public').default
}
]
}
diff --git a/src/renderer/store/TimelineSpace.js b/src/renderer/store/TimelineSpace.js
index 11b680e6..324b031e 100644
--- a/src/renderer/store/TimelineSpace.js
+++ b/src/renderer/store/TimelineSpace.js
@@ -3,6 +3,7 @@ import Mastodon from 'mastodon-api'
import SideMenu from './TimelineSpace/SideMenu'
import Favourites from './TimelineSpace/Favourites'
import Local from './TimelineSpace/Local'
+import Public from './TimelineSpace/Public'
import router from '../router'
const TimelineSpace = {
@@ -10,7 +11,8 @@ const TimelineSpace = {
modules: {
SideMenu,
Favourites,
- Local
+ Local,
+ Public
},
state: {
account: {
diff --git a/src/renderer/store/TimelineSpace/Public.js b/src/renderer/store/TimelineSpace/Public.js
new file mode 100644
index 00000000..ee03f2ae
--- /dev/null
+++ b/src/renderer/store/TimelineSpace/Public.js
@@ -0,0 +1,33 @@
+import { ipcRenderer } from 'electron'
+
+const Public = {
+ namespaced: true,
+ state: {
+ timeline: []
+ },
+ mutations: {
+ appendTimeline (state, update) {
+ state.timeline = [update].concat(state.timeline)
+ }
+ },
+ actions: {
+ startPublicStreaming ({ commit }, account) {
+ ipcRenderer.on('update-start-public-streaming', (event, update) => {
+ commit('appendTimeline', update)
+ })
+ return new Promise((resolve, reject) => {
+ ipcRenderer.send('start-public-streaming', account)
+ ipcRenderer.once('error-start-public-streaming', (event, err) => {
+ reject(err)
+ })
+ })
+ },
+ stopPublicStreaming ({ commit }) {
+ ipcRenderer.removeAllListeners('error-start-public-streaming')
+ ipcRenderer.removeAllListeners('update-start-public-streaming')
+ ipcRenderer.send('stop-public-streaming')
+ }
+ }
+}
+
+export default Public