refs #921 Show error message when failed to start streamings

This commit is contained in:
AkiraFukushima 2019-06-27 21:58:43 +09:00
parent f27f816fe5
commit 97b05e78c5
11 changed files with 47 additions and 22 deletions

View File

@ -51,6 +51,7 @@
},
"message": {
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request"
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
}
}

View File

@ -348,6 +348,7 @@
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request",
"start_streaming_error": "Failed to start streaming",
"start_all_streamings_error": "Failed to start streaming of {{domain}}",
"attach_error": "Could not attach the file",
"authorize_duplicate_error": "Can not login the same account of the same domain",
"authorize_error": "Failed to authorize",

View File

@ -17,6 +17,7 @@
},
"message": {
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request"
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
}
}

View File

@ -17,6 +17,7 @@
},
"message": {
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request"
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
}
}

View File

@ -339,6 +339,7 @@
"follow_request_accept_error": "フォローリクエストの承認に失敗しました",
"follow_reuqest_reject_error": "フォローリクエストの却下に失敗しました",
"start_streaming_error": "ストリーミングを開始できませんでした",
"start_all_streamings_error": "{{domain}}のストリーミングを開始できませんでした",
"attach_error": "ファイルを添付できませんでした",
"authorize_duplicate_error": "同一ドメイン同一アカウントではログインできません",
"authorize_error": "認証に失敗しました",

View File

@ -26,6 +26,7 @@
},
"message": {
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request"
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
}
}

View File

@ -51,6 +51,7 @@
},
"message": {
"follow_request_accept_error": "Failed to accept the request",
"follow_reuqest_reject_error": "failed to reject the request"
"follow_reuqest_reject_error": "failed to reject the request",
"start_all_streamings_error": "Failed to start streaming of {{domain}}"
}
}

View File

@ -0,0 +1,6 @@
export class StreamingError extends Error {
constructor(message, domain) {
super(message)
this.domain = domain
}
}

View File

@ -35,6 +35,7 @@ import { LocalAccount } from '~/src/types/localAccount'
import { LocalTag } from '~/src/types/localTag'
import { UnreadNotification as UnreadNotificationConfig } from '~/src/types/unreadNotification'
import { AccountNotification } from '~/src/types/accountNotification'
import { StreamingError } from '~/src/errors/streamingError'
/**
* Context menu
@ -475,9 +476,10 @@ ipcMain.on('start-all-user-streamings', (event: Event, accounts: Array<LocalAcco
}
)
})
.catch(err => {
.catch((err: Error) => {
log.error(err)
event.sender.send('error-start-all-user-streamings', err)
const streamingError = new StreamingError(err.message, account.domain)
event.sender.send('error-start-all-user-streamings', streamingError)
})
})
})

View File

@ -31,6 +31,7 @@
<script>
import { mapState } from 'vuex'
import FailoverImg from '~/src/renderer/components/atoms/FailoverImg'
import { StreamingError } from '~/src/errors/streamingError'
export default {
name: 'global-header',
@ -54,14 +55,24 @@ export default {
return this.$route.path
},
async initialize() {
try {
const accounts = await this.$store.dispatch('GlobalHeader/initLoad')
if (this.$route.params.id === undefined) {
return this.$router.push({ path: `/${accounts[0]._id}/home` })
}
} catch (err) {
return this.$router.push({ path: '/login' })
}
await this.$store
.dispatch('GlobalHeader/initLoad')
.then(accounts => {
this.$store.dispatch('GlobalHeader/startStreamings').catch(err => {
if (err instanceof StreamingError) {
this.$message({
message: this.$t('message.start_all_streamings_error', { domain: err.domain }),
type: 'error'
})
}
})
if (this.$route.params.id === undefined) {
this.$router.push({ path: `/${accounts[0]._id}/home` })
}
})
.catch(_ => {
return this.$router.push({ path: '/login' })
})
}
}
}

View File

@ -7,6 +7,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import { Notify } from '~/src/types/notify'
import { AccountNotification } from '~/src/types/accountNotification'
import { StreamingError } from '~src/errors/streamingError'
declare var Notification: any
@ -51,14 +52,12 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
console.error(err)
}
const accounts = await dispatch('listAccounts')
try {
dispatch('bindUserStreamingsForNotify')
dispatch('startUserStreamings')
} catch (err) {
console.error(err)
}
return accounts
},
startStreamings: async ({ dispatch }) => {
dispatch('bindUserStreamingsForNotify')
dispatch('startUserStreamings')
},
listAccounts: ({ dispatch, commit }): Promise<Array<LocalAccount>> => {
return new Promise((resolve, reject) => {
ipcRenderer.send('list-accounts', 'list')
@ -132,7 +131,7 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
startUserStreamings: ({ state }): Promise<{}> => {
// @ts-ignore
return new Promise((resolve, reject) => {
ipcRenderer.once('error-start-all-user-streamings', (_, err: Error) => {
ipcRenderer.once('error-start-all-user-streamings', (_, err: StreamingError) => {
reject(err)
})
ipcRenderer.send('start-all-user-streamings', state.accounts)