Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Feature/hooks websockets#124

Merged
pablo-rodriguez-jd merged 10 commits intodevelopfrom
feature/hooks-websockets
Mar 22, 2019
Merged

Feature/hooks websockets#124
pablo-rodriguez-jd merged 10 commits intodevelopfrom
feature/hooks-websockets

Conversation

@jairo-campos-JD
Copy link
Contributor

hooks, websockets updates, This will need to update @inrupt/solid-react-component package. Please do not merge it yet.

@jairo-campos-JD jairo-campos-JD changed the base branch from release/0.4.0 to develop March 21, 2019 16:08
try {
if (webId) {
// We are fetching profile card document
const user = data[webId];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will webId always be the current user?

If yes, then why not data.user (and not pass in webId)?

If no, then perhaps calling it user is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's a user I updated to data.user thank you !!!

Copy link

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but consider paying more attention to simplifying code: there are several repeated patterns that take many lines, for which you can create or reuse an existing helper.

toastManager.add (['Error', error.message], {
appearance: 'error',
});
}
Copy link

@RubenVerborgh RubenVerborgh Mar 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to write the above much more easily as follows:

const image = useLDflexValue(`[${webId}].image`);
const photo = useLDflexValue(`[${webId}].vcard$hasPhoto`);
const src = image || photo;

const {user} = data;
image
? await user.image.set (uri)
: await user.image.add (uri);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just set will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you right, done.

toastManager.add (['Error', error.message], {
appearance: 'error',
});
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your toastManager code takes up a lot of lines.
Consider creating shortcuts like toastManager.success and toastManager.error.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can even avoid the catch if you write a helper like

toastManager.report(async () => {
}, "Profile image update");

with

toastManager.report = async function(action, successMsg) {
   try { await action(); }
   catch (error) { toastManager.error(error); return; }
   toastManager.success(successMsg);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to remove this toastsManager and create a new one to avoid the use of consumer in all places, so I don't know if we need to do this refactor since we will remove it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants