Skip to content

Commit

Permalink
Using new useSession hook
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloamorimbr committed Nov 28, 2024
1 parent 980f73a commit 0036e25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions jsapp/js/account/accountSettingsRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import bem, {makeBem} from 'js/bem';
import sessionStore from 'js/stores/session';
import './accountSettings.scss';
import {notify} from 'js/utils';
import type {AccountResponse} from '../dataInterface';
import {dataInterface} from '../dataInterface';
import AccountFieldsEditor from './accountFieldsEditor.component';
import Avatar from 'js/components/common/avatar';
Expand Down Expand Up @@ -39,7 +38,6 @@ const AccountSettings = () => {
Partial<AccountFieldsValues>
>({});

// We're verifying that the user is logged in so we can consider the current account is from a valid logged user
const {currentLoggedAccount} = useSession();

useEffect(() => {
Expand Down
10 changes: 4 additions & 6 deletions jsapp/js/tos/tosForm.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
AccountFieldsErrors,
} from 'js/account/account.constants';
import {currentLang, notify} from 'js/utils';
import {useLocalObservable} from 'mobx-react';
import {useSession} from '../stores/useSession';

/** A slug for the `sitewide_messages` endpoint */
const TOS_SLUG = 'terms_of_service';
Expand Down Expand Up @@ -72,9 +72,7 @@ export default function TOSForm() {
fieldsToShow.push('newsletter_subscription');
}

const currentAccount = useLocalObservable(
() => sessionStore.currentAccount as AccountResponse
);
const {currentLoggedAccount} = useSession();

// Get TOS message from endpoint
useEffect(() => {
Expand Down Expand Up @@ -117,7 +115,7 @@ export default function TOSForm() {
// (including the non-required ones that will be hidden, but passed to the API
// so that they will not get erased).
useEffect(() => {
if (!currentAccount) {
if (!currentLoggedAccount) {
return;
}

Expand All @@ -138,7 +136,7 @@ export default function TOSForm() {
instagram: data.extra_details.instagram,
newsletter_subscription: data.extra_details.newsletter_subscription,
});
}, [currentAccount]);
}, [currentLoggedAccount]);

const onFieldChange = (fieldName: string, value: string | boolean) => {
setFormFields({
Expand Down

0 comments on commit 0036e25

Please sign in to comment.