Accept JSX into the GenericErrorPage and expose local session vars

pull/21833/head
Travis Ralston 2019-05-29 12:09:04 -06:00
parent 76cd829ac9
commit 5c85f4609e
3 changed files with 11 additions and 6 deletions

View File

@ -14,6 +14,6 @@
width: 500px;
height: 200px;
border: 1px solid #f22;
padding: 10px;
padding: 10px 10px 20px;
background-color: #fcc;
}

View File

@ -122,7 +122,7 @@ export async function loadSession(opts) {
* @returns {String} The persisted session's owner, if an owner exists. Null otherwise.
*/
export function getStoredSessionOwner() {
const {hsUrl, userId, accessToken} = _getLocalStorageSessionVars();
const {hsUrl, userId, accessToken} = getLocalStorageSessionVars();
return hsUrl && userId && accessToken ? userId : null;
}
@ -131,7 +131,7 @@ export function getStoredSessionOwner() {
* for a real user. If there is no stored session, return null.
*/
export function getStoredSessionIsGuest() {
const sessVars = _getLocalStorageSessionVars();
const sessVars = getLocalStorageSessionVars();
return sessVars.hsUrl && sessVars.userId && sessVars.accessToken ? sessVars.isGuest : null;
}
@ -237,7 +237,12 @@ function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) {
});
}
function _getLocalStorageSessionVars() {
/**
* Retrieves information about the stored session in localstorage. The session
* may not be valid, as it is not tested for consistency here.
* @returns {Object} Information about the session - see implementation for variables.
*/
export function getLocalStorageSessionVars() {
const hsUrl = localStorage.getItem("mx_hs_url");
const isUrl = localStorage.getItem("mx_is_url") || 'https://matrix.org';
const accessToken = localStorage.getItem("mx_access_token");
@ -270,7 +275,7 @@ async function _restoreFromLocalStorage() {
return false;
}
const {hsUrl, isUrl, accessToken, userId, deviceId, isGuest} = _getLocalStorageSessionVars();
const {hsUrl, isUrl, accessToken, userId, deviceId, isGuest} = getLocalStorageSessionVars();
if (accessToken && userId && hsUrl) {
console.log(`Restoring session for ${userId}`);

View File

@ -20,7 +20,7 @@ import {_t} from "../../languageHandler";
export default class GenericErrorPage extends React.PureComponent {
static propTypes = {
message: PropTypes.string.isRequired,
message: PropTypes.object.isRequired, // jsx to display
};
render() {