Skip to content

Commit

Permalink
fixed relay user save profile error (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty authored Sep 22, 2023
1 parent 4a9863a commit 82ff893
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
21 changes: 13 additions & 8 deletions frontend/app/src/people/main/FocusView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ const B = styled.div<BProps>`
overflow-y: auto;
box-sizing: border-box;
${EnvWithScrollBar({
thumbColor: '#5a606c',
trackBackgroundColor: 'rgba(0,0,0,0)'
})}
thumbColor: '#5a606c',
trackBackgroundColor: 'rgba(0,0,0,0)'
})}
`;
function FocusedView(props: FocusViewProps) {
const {
Expand Down Expand Up @@ -103,9 +103,9 @@ function FocusedView(props: FocusViewProps) {

const userOrganizations = main.organizations.length
? main.organizations.map((org: Organization) => ({
label: toCapitalize(org.name),
value: org.uuid
}))
label: toCapitalize(org.name),
value: org.uuid
}))
: [];

function isNotHttps(url: string | undefined) {
Expand Down Expand Up @@ -206,6 +206,7 @@ function FocusedView(props: FocusViewProps) {
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
async function submitForm(body: any, shouldCloseModal: boolean = true) {
let newBody = cloneDeep(body);

if (config && config.name === 'about') {
const res = await main.saveProfile(newBody);
if (shouldCloseModal) {
Expand All @@ -226,9 +227,11 @@ function FocusedView(props: FocusViewProps) {
if (!newBody.description) {
addToast();
}

const info = ui.meInfo as any;
if (!info) return console.log('no meInfo');
setLoading(true);

try {
if (typeof newBody?.assignee !== 'string' || !newBody?.assignee) {
newBody.assignee = newBody.assignee?.owner_pubkey ?? 'emptyid';
Expand All @@ -250,7 +253,9 @@ function FocusedView(props: FocusViewProps) {
} catch (e) {
console.log('e', e);
}

if (props?.onSuccess) props.onSuccess();

setLoading(false);
if (ui?.meInfo?.hasOwnProperty('url') && !isNotHttps(ui?.meInfo?.url) && props?.ReCallBounties)
props?.ReCallBounties();
Expand Down Expand Up @@ -380,8 +385,8 @@ function FocusedView(props: FocusViewProps) {
extraHTML={
ui.meInfo.verification_signature
? {
twitter: `<span>Post this to your twitter account to verify:</span><br/><strong>Sphinx Verification: ${ui.meInfo.verification_signature}</strong>`
}
twitter: `<span>Post this to your twitter account to verify:</span><br/><strong>Sphinx Verification: ${ui.meInfo.verification_signature}</strong>`
}
: {}
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { formConfig } from './config';

export const EditUserDesktopView = observer(() => {
const { canEdit, closeHandler, person, modals } = useUserEdit();

return (
<Modal
visible={modals.userEditModal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function WantedSummary(props: WantedSummaryProps) {
type: type,
created: created
};

formSubmit && formSubmit(newValue);
},
[
Expand Down
6 changes: 4 additions & 2 deletions frontend/app/src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,12 +1256,14 @@ export class MainStore {
// first time profile makers will need this on first login
if (!body.id) {
const j = await r.json();
if (j.response.id) {
if (j.response && j.response.id) {
body.id = j.response.id;
}
}

await this.getSelf(body);
const updateSelf = { ...info, ...body };
await this.getSelf(updateSelf);

uiStore.setToasts([
{
id: '1',
Expand Down

0 comments on commit 82ff893

Please sign in to comment.