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);
|
||||
}
|
||||
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) => {
|
||||
setInputToken(token);
|
||||
|
@ -18,6 +18,7 @@ import {
|
||||
} from '../models';
|
||||
|
||||
import { apiClient } from '../services/api';
|
||||
import { systemClient } from '../services/System';
|
||||
import { checkVer, getHost, tokenStrength } from '../utils';
|
||||
import { sha256 } from 'js-sha256';
|
||||
|
||||
@ -252,7 +253,7 @@ export const AppContextProvider = ({
|
||||
useEffect(() => {
|
||||
window.addEventListener('torStatus', (event) => {
|
||||
// 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);
|
||||
garage.updateRobot(newRobot, targetSlot);
|
||||
setCurrentSlot(targetSlot);
|
||||
systemClient.setItem('robot_token', token);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -10,16 +10,19 @@ class ApiNativeClient implements ApiClient {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
const sessionid = systemClient.getCookie('sessionid');
|
||||
const csrftoken = systemClient.getCookie('csrftoken');
|
||||
const robotToken = systemClient.getItem('robot_token');
|
||||
if (robotToken) {
|
||||
const sessionid = systemClient.getCookie('sessionid');
|
||||
const csrftoken = systemClient.getCookie('csrftoken');
|
||||
|
||||
headers = {
|
||||
...headers,
|
||||
...{
|
||||
'X-CSRFToken': csrftoken,
|
||||
Cookie: `sessionid=${sessionid};token=${csrftoken}`,
|
||||
},
|
||||
};
|
||||
headers = {
|
||||
...headers,
|
||||
...{
|
||||
'X-CSRFToken': csrftoken,
|
||||
Cookie: `sessionid=${sessionid};csrftoken=${csrftoken}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return headers;
|
||||
};
|
||||
|
@ -45,6 +45,7 @@ const App = () => {
|
||||
|
||||
EncryptedStorage.removeItem('sessionid');
|
||||
EncryptedStorage.removeItem('csrftoken');
|
||||
loadCookie('robot_token');
|
||||
loadCookie('settings_fontsize_basic');
|
||||
loadCookie('settings_language');
|
||||
loadCookie('settings_mode');
|
||||
|
Loading…
Reference in New Issue
Block a user