mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
parent
cee6ffbf45
commit
8d4301a0c0
@ -43,9 +43,11 @@ const RobotPage = (): JSX.Element => {
|
|||||||
setInputToken(robot.token);
|
setInputToken(robot.token);
|
||||||
}
|
}
|
||||||
if (robot.nickname == null && robot.token) {
|
if (robot.nickname == null && robot.token) {
|
||||||
fetchRobot({ action: 'generate', setBadRequest });
|
if (window.NativeRobosats === undefined || torStatus == '"Done"') {
|
||||||
|
fetchRobot({ action: 'generate', setBadRequest });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, [torStatus]);
|
||||||
|
|
||||||
const getGenerateRobot = (token: string, slot?: number) => {
|
const getGenerateRobot = (token: string, slot?: number) => {
|
||||||
setInputToken(token);
|
setInputToken(token);
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
} from '../models';
|
} from '../models';
|
||||||
|
|
||||||
import { apiClient } from '../services/api';
|
import { apiClient } from '../services/api';
|
||||||
|
import { systemClient } from '../services/System';
|
||||||
import { checkVer, getHost, tokenStrength } from '../utils';
|
import { checkVer, getHost, tokenStrength } from '../utils';
|
||||||
import { sha256 } from 'js-sha256';
|
import { sha256 } from 'js-sha256';
|
||||||
|
|
||||||
@ -252,7 +253,7 @@ export const AppContextProvider = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener('torStatus', (event) => {
|
window.addEventListener('torStatus', (event) => {
|
||||||
// UX improv: delay the "Conencted" status by 10 secs to avoid long waits for first requests
|
// UX improv: delay the "Conencted" status by 10 secs to avoid long waits for first requests
|
||||||
setTimeout(() => setTorStatus(event?.detail), event?.detail === '"Done"' ? 10000 : 0);
|
setTimeout(() => setTorStatus(event?.detail), event?.detail === '"Done"' ? 5000 : 0);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -465,6 +466,7 @@ export const AppContextProvider = ({
|
|||||||
setRobot(newRobot);
|
setRobot(newRobot);
|
||||||
garage.updateRobot(newRobot, targetSlot);
|
garage.updateRobot(newRobot, targetSlot);
|
||||||
setCurrentSlot(targetSlot);
|
setCurrentSlot(targetSlot);
|
||||||
|
systemClient.setItem('robot_token', token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -10,16 +10,19 @@ class ApiNativeClient implements ApiClient {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
};
|
};
|
||||||
|
|
||||||
const sessionid = systemClient.getCookie('sessionid');
|
const robotToken = systemClient.getItem('robot_token');
|
||||||
const csrftoken = systemClient.getCookie('csrftoken');
|
if (robotToken) {
|
||||||
|
const sessionid = systemClient.getCookie('sessionid');
|
||||||
|
const csrftoken = systemClient.getCookie('csrftoken');
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
...headers,
|
...headers,
|
||||||
...{
|
...{
|
||||||
'X-CSRFToken': csrftoken,
|
'X-CSRFToken': csrftoken,
|
||||||
Cookie: `sessionid=${sessionid};token=${csrftoken}`,
|
Cookie: `sessionid=${sessionid};csrftoken=${csrftoken}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return headers;
|
return headers;
|
||||||
};
|
};
|
||||||
|
@ -45,6 +45,7 @@ const App = () => {
|
|||||||
|
|
||||||
EncryptedStorage.removeItem('sessionid');
|
EncryptedStorage.removeItem('sessionid');
|
||||||
EncryptedStorage.removeItem('csrftoken');
|
EncryptedStorage.removeItem('csrftoken');
|
||||||
|
loadCookie('robot_token');
|
||||||
loadCookie('settings_fontsize_basic');
|
loadCookie('settings_fontsize_basic');
|
||||||
loadCookie('settings_language');
|
loadCookie('settings_language');
|
||||||
loadCookie('settings_mode');
|
loadCookie('settings_mode');
|
||||||
|
Loading…
Reference in New Issue
Block a user