Fix session replica behaviour (merge with session)
The harder-to-refactor parts are the places where exists/username/token are called within a React component. However, `resetAndRedirect` and `store` are already called from async contexts, so adding an `await` is simple. This thus merges the logic, keeping localStorage for the components to call, but making sure reset/store behaviour works correctly for the replica.
This commit is contained in:
@@ -39,7 +39,7 @@ export const subscribeTopic = async (baseUrl, topic, opts) => {
|
||||
} catch (e) {
|
||||
console.log(`[SubscribeDialog] Subscribing to topic ${topic} failed`, e);
|
||||
if (e instanceof UnauthorizedError) {
|
||||
session.resetAndRedirect(routes.login);
|
||||
await session.resetAndRedirect(routes.login);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ const SubscribePage = (props) => {
|
||||
} catch (e) {
|
||||
console.log(`[SubscribeDialog] Error reserving topic`, e);
|
||||
if (e instanceof UnauthorizedError) {
|
||||
session.resetAndRedirect(routes.login);
|
||||
await session.resetAndRedirect(routes.login);
|
||||
} else if (e instanceof TopicReservedError) {
|
||||
setError(t("subscribe_dialog_error_topic_already_reserved"));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user