diff options
| author | Henry Jameson <me@hjkos.com> | 2019-11-24 18:50:28 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2019-11-24 18:50:28 +0200 |
| commit | 319bb4ac2895b8eb62da42e3f95addc9bb67b1a0 (patch) | |
| tree | de24974025e9df8ca77b6417df3813e1722beeec /src/modules/api.js | |
| parent | ddb6fb9217789e90490a4ec1ce7a2dd9ced67631 (diff) | |
initial streaming work
Diffstat (limited to 'src/modules/api.js')
| -rw-r--r-- | src/modules/api.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/modules/api.js b/src/modules/api.js index 1293e3c8..1bf65db5 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -6,6 +6,7 @@ const api = { backendInteractor: backendInteractorService(), fetchers: {}, socket: null, + mastoSocket: null, followRequests: [] }, mutations: { @@ -29,6 +30,20 @@ const api = { } }, actions: { + startMastoSocket (store) { + store.state.mastoSocket = store.state.backendInteractor + .startUserSocket({ + store, + onMessage: (message) => { + if (!message) return + if (message.event === 'notification') { + store.dispatch('addNewNotifications', { notifications: [message.notification], older: false }) + } else if (message.event === 'update') { + store.dispatch('addNewStatuses', { statuses: [message.status], userId: false, showImmediately: false, timeline: 'friends' }) + } + } + }) + }, startFetchingTimeline (store, { timeline = 'friends', tag = false, userId = false }) { // Don't start fetching if we already are. if (store.state.fetchers[timeline]) return |
