use promise for setAuthToken so we only continue after the auth token has been set
This commit is contained in:
parent
b773badef1
commit
46b47c3f8f
1 changed files with 26 additions and 19 deletions
|
@ -34,8 +34,13 @@ autoUpdater.logger = remote.require('electron-log');
|
||||||
|
|
||||||
// We need to override Lbryio for getting/setting the authToken
|
// We need to override Lbryio for getting/setting the authToken
|
||||||
// We interect with ipcRenderer to get the auth key from a users keyring
|
// We interect with ipcRenderer to get the auth key from a users keyring
|
||||||
|
// We keep a local variable for authToken beacuse `ipcRenderer.send` does not
|
||||||
|
// contain a response, so there is no way to know when it's been set
|
||||||
let authToken;
|
let authToken;
|
||||||
Lbryio.setOverride('setAuthToken', status => {
|
Lbryio.setOverride(
|
||||||
|
'setAuthToken',
|
||||||
|
status =>
|
||||||
|
new Promise(resolve => {
|
||||||
Lbryio.call(
|
Lbryio.call(
|
||||||
'user',
|
'user',
|
||||||
'new',
|
'new',
|
||||||
|
@ -53,8 +58,10 @@ Lbryio.setOverride('setAuthToken', status => {
|
||||||
const newAuthToken = response.auth_token;
|
const newAuthToken = response.auth_token;
|
||||||
authToken = newAuthToken;
|
authToken = newAuthToken;
|
||||||
ipcRenderer.send('set-auth-token', authToken);
|
ipcRenderer.send('set-auth-token', authToken);
|
||||||
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
|
||||||
Lbryio.setOverride(
|
Lbryio.setOverride(
|
||||||
'getAuthToken',
|
'getAuthToken',
|
||||||
|
|
Loading…
Reference in a new issue