1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2025-01-11 08:24:58 +01:00

refs #105 Get account information from rootState

This commit is contained in:
AkiraFukushima 2018-03-24 01:50:42 +09:00
parent c70251e9a9
commit 1dd04b9f3c
2 changed files with 7 additions and 8 deletions

View File

@ -15,7 +15,6 @@ export default {
components: { Toot },
computed: {
...mapState({
account: state => state.TimelineSpace.account,
timeline: state => state.TimelineSpace.Local.timeline
})
},
@ -40,14 +39,14 @@ export default {
methods: {
async initialize () {
try {
await this.$store.dispatch('TimelineSpace/Local/fetchLocalTimeline', this.account)
await this.$store.dispatch('TimelineSpace/Local/fetchLocalTimeline')
} catch (err) {
this.$message({
message: 'Could not fetch timeline',
type: 'error'
})
}
this.$store.dispatch('TimelineSpace/Local/startLocalStreaming', this.account)
this.$store.dispatch('TimelineSpace/Local/startLocalStreaming')
},
updateToot (message) {
this.$store.commit('TimelineSpace/Local/updateToot', message)

View File

@ -31,12 +31,12 @@ const Local = {
}
},
actions: {
fetchLocalTimeline ({ commit }, account) {
fetchLocalTimeline ({ state, commit, rootState }) {
return new Promise((resolve, reject) => {
const client = new Mastodon(
{
access_token: account.accessToken,
api_url: account.baseURL + '/api/v1'
access_token: rootState.TimelineSpace.account.accessToken,
api_url: rootState.TimelineSpace.account.baseURL + '/api/v1'
}
)
client.get('/timelines/public', { limit: 40, local: true }, (err, data, res) => {
@ -46,12 +46,12 @@ const Local = {
})
})
},
startLocalStreaming ({ commit }, account) {
startLocalStreaming ({ state, commit, rootState }) {
ipcRenderer.on('update-start-local-streaming', (event, update) => {
commit('appendTimeline', update)
})
return new Promise((resolve, reject) => {
ipcRenderer.send('start-local-streaming', account)
ipcRenderer.send('start-local-streaming', rootState.TimelineSpace.account)
ipcRenderer.once('error-start-local-streaming', (event, err) => {
reject(err)
})