From b6ecfbb91f898fdb459cc802cd7de99daa59e215 Mon Sep 17 00:00:00 2001 From: "@wwwjim" Date: Sat, 21 Nov 2020 18:24:26 -0800 Subject: [PATCH] patches viewer.onboarding bug --- common/user-behaviors.js | 3 +-- components/core/Application.js | 18 ++++++++++++++++-- components/core/SignIn.js | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/common/user-behaviors.js b/common/user-behaviors.js index deaf9b75..e6a458a8 100644 --- a/common/user-behaviors.js +++ b/common/user-behaviors.js @@ -13,8 +13,6 @@ const cookies = new Cookies(); // NOTE(martina): Creates a new user, then authenticates them export const createUser = async (state) => { let response = await Actions.createUser(state); - console.log("CREATE_USER", response); - if (!response || response.error) { return response; } @@ -115,6 +113,7 @@ export const hydrate = async () => { }); return null; } + return JSON.parse(JSON.stringify(response.data)); }; diff --git a/components/core/Application.js b/components/core/Application.js index d926b3a9..0277ef25 100644 --- a/components/core/Application.js +++ b/components/core/Application.js @@ -396,6 +396,14 @@ export default class ApplicationPage extends React.Component { _handleCreateUser = async (state) => { let response = await Actions.createUser(state); if (!response || response.error) { + dispatchCustomEvent({ + name: "create-alert", + detail: { + alert: { + message: "We had an issue creating your user account.", + }, + }, + }); return response; } @@ -404,14 +412,20 @@ export default class ApplicationPage extends React.Component { _handleAuthenticate = async (state, newAccount) => { let response = await UserBehaviors.authenticate(state, newAccount); + if (!response || response.error) { + return; + } + let viewer = await UserBehaviors.hydrate(); + console.log(viewer); + this.setState({ viewer }); await this._handleSetupWebsocket(); let unseenAnnouncements = []; for (let feature of announcements) { - if (!Object.keys(this.state.viewer.onboarding).includes(feature)) { + if (!Object.keys(viewer.onboarding).includes(feature)) { unseenAnnouncements.push(feature); } } @@ -423,7 +437,7 @@ export default class ApplicationPage extends React.Component { modal: ( diff --git a/components/core/SignIn.js b/components/core/SignIn.js index 99ff4a46..78b5e2ac 100644 --- a/components/core/SignIn.js +++ b/components/core/SignIn.js @@ -175,7 +175,7 @@ export class SignIn extends React.Component { name: "create-alert", detail: { alert: { - message: "1We're having trouble connecting right now. Please try again later.", + message: "We're having trouble connecting right now. Please try again later.", }, }, });