refs #3 Display message when could not found instance
This commit is contained in:
parent
35ed16230b
commit
0664b137c9
|
@ -6,6 +6,7 @@
|
|||
<el-radio class="instance-list" v-for="instance in instances" v-bind:key="instance.id" :label="instance.name" border></el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<p v-if="instances.length === 0">Could not find instance</p>
|
||||
<el-form-item class="submit">
|
||||
<el-button type="text" class="back" @click="back"><icon name="chevron-left"></icon></el-button>
|
||||
<el-button type="primary" class="login" @click="login" v-if="selectedInstance !== null">Login</el-button>
|
||||
|
|
|
@ -8,11 +8,11 @@ const Authorize = {
|
|||
submit ({ commit }, code) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.send('get-access-token', code)
|
||||
ipcRenderer.on('response-get-access-token', (event, id) => {
|
||||
ipcRenderer.once('response-get-access-token', (event, id) => {
|
||||
console.log(id)
|
||||
resolve(id)
|
||||
})
|
||||
ipcRenderer.on('error-get-access-token', (event, err) => {
|
||||
ipcRenderer.once('error-get-access-token', (event, err) => {
|
||||
console.log(err)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -3,22 +3,22 @@ import { ipcRenderer } from 'electron'
|
|||
const GlobalHeader = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
instances: []
|
||||
accounts: []
|
||||
},
|
||||
mutations: {
|
||||
updateInstances (state, instances) {
|
||||
state.instances = instances
|
||||
updateAccounts (state, accounts) {
|
||||
state.accounts = accounts
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
listInstances ({ commit }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.send('list-instances', 'list')
|
||||
ipcRenderer.on('error-list-instances', (event, err) => {
|
||||
ipcRenderer.once('error-list-instances', (event, err) => {
|
||||
reject(err)
|
||||
})
|
||||
ipcRenderer.on('response-list-instances', (event, instances) => {
|
||||
commit('updateInstances', instances)
|
||||
ipcRenderer.once('response-list-instances', (event, instances) => {
|
||||
commit('updateAccounts', instances)
|
||||
resolve(instances)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -21,12 +21,13 @@ const Login = {
|
|||
},
|
||||
actions: {
|
||||
searchInstance ({ commit }, domain) {
|
||||
console.log(domain)
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.send('get-social-token', 'get')
|
||||
ipcRenderer.on('error-get-social-token', (event, err) => {
|
||||
ipcRenderer.once('error-get-social-token', (event, err) => {
|
||||
reject(err)
|
||||
})
|
||||
ipcRenderer.on('response-get-social-token', (event, token) => {
|
||||
ipcRenderer.once('response-get-social-token', (event, token) => {
|
||||
axios
|
||||
.get(`https://instances.social/api/1.0/instances/search?q=${domain}`, {
|
||||
'headers': { 'Authorization': `Bearer ${token}` }
|
||||
|
@ -41,10 +42,10 @@ const Login = {
|
|||
fetchLogin ({ commit }, instance) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.send('get-auth-url', instance)
|
||||
ipcRenderer.on('error-get-auth-url', (event, err) => {
|
||||
ipcRenderer.once('error-get-auth-url', (event, err) => {
|
||||
reject(err)
|
||||
})
|
||||
ipcRenderer.on('response-get-auth-url', (event, url) => {
|
||||
ipcRenderer.once('response-get-auth-url', (event, url) => {
|
||||
resolve(url)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -21,21 +21,21 @@ const SideMenu = {
|
|||
actions: {
|
||||
fetchInstance ({ commit }, id) {
|
||||
ipcRenderer.send('get-instance', id)
|
||||
ipcRenderer.on('error-get-instance', (event, err) => {
|
||||
ipcRenderer.once('error-get-instance', (event, err) => {
|
||||
// TODO: handle error
|
||||
console.log(err)
|
||||
})
|
||||
ipcRenderer.on('response-get-instance', (event, instance) => {
|
||||
ipcRenderer.once('response-get-instance', (event, instance) => {
|
||||
commit('updateInstance', instance)
|
||||
})
|
||||
},
|
||||
username ({ commit }, id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ipcRenderer.send('get-local-account', id)
|
||||
ipcRenderer.on('error-get-local-account', (event, err) => {
|
||||
ipcRenderer.once('error-get-local-account', (event, err) => {
|
||||
reject(err)
|
||||
})
|
||||
ipcRenderer.on('response-get-local-account', (event, account) => {
|
||||
ipcRenderer.once('response-get-local-account', (event, account) => {
|
||||
const client = new Mastodon(
|
||||
{
|
||||
access_token: account.accessToken,
|
||||
|
|
Loading…
Reference in New Issue