Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/pack file restructure part I #377

Merged
merged 9 commits into from Aug 29, 2018
Merged

Task/pack file restructure part I #377

merged 9 commits into from Aug 29, 2018

Conversation

nickytonline
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Documentation Update

Description

Part of the work for #327. Casing of JSX files have been made uniform to follow PascalCasing. See https://github.com/airbnb/javascript/tree/master/react#naming. Also the onboarding entry point is now name properly, pack.js -> Onboarding.jsx

Added to documentation?

  • docs.dev.to
  • readme
  • no documentation needed

[optional] What gif best describes this PR or how it makes you feel?

alt-text

@nickytonline
Copy link
Contributor Author

Looks like even just this minimal file restructure requires refactoring of code as I mentioned in #373 (comment).

@nickytonline nickytonline changed the title Task/pack file restructure [WIP] Task/pack file restructure Aug 23, 2018
}

function renderPage() {
import('../src/Onboarding')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@benhalpern, you'll like this performance tweak. We only load onboarding if the user is signed in and hasn't previously seen the onboarding. Before, the component was imported all the time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do. I'm also excited to improve on several fronts here.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is great!

)
.catch(error => {
// eslint-disable-next-line no-console
console.error('Unable to load onboarding', error);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that there is airbrake for the back-end, but from what I can tell, we don't use any client-side error reporting services. Consider a package for handling client-side errors as we'll creating more and more in the front-end now.

@@ -1,71 +0,0 @@
import { h, render } from 'preact';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been renamed from chat.jsx to Chat.jsx as per eslint rules.

@@ -1,40 +0,0 @@
import { h, render } from 'preact';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been renamed from pack.jsx to Onboarding.jsx as that is really what this pack file is for.

//Not yet ready
if (!window.location.href.includes('ask-for-notifications')){
return "dont-ask"
// Not yet ready
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A little note for whoever comes across this PR, there are only three permissions available. See https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission


return permission === 'default' ? 'waiting-permission' : permission;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there are only three possible permission types, https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission, I'm assuming when it's 'default' @benhalpern, you wish it to be set to 'waiting-permission'?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah.

@nickytonline nickytonline changed the title [WIP] Task/pack file restructure [WIP] Task/pack file restructure part I Aug 26, 2018
@nickytonline
Copy link
Contributor Author

As @rhymes mentioned in another issue/PR, there are vulnerablilities detected which makes CI crap out.

navigator.serviceWorker.ready.then((serviceWorkerRegistration) => {
serviceWorkerRegistration.pushManager.getSubscription()
.then(function(subscription) {
navigator.serviceWorker.ready.then(serviceWorkerRegistration => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

prettier in action here.

getUserDataAndCsrfToken()
.then(loadChat)
.catch(error => {
// eslint-disable-next-line no-console
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As mentioned elsewhere, client-side error reporting should be put in place.

@nickytonline nickytonline changed the title [WIP] Task/pack file restructure part I Task/pack file restructure part I Aug 26, 2018
@nickytonline
Copy link
Contributor Author

@maestromac, @benhalpern or the Internet, this is ready for a review.

@nickytonline
Copy link
Contributor Author

nickytonline commented Aug 26, 2018

@maestromac, code climate was all fixed but since I pushed my last commit (just tests), now 38 more issues popped up.

Given that this PR really was just to move some files, I think the additional issues to fix should come in another PR, especially since all the new code climate issues that just appeared after my last commit (just tests) are not even in the files I changed.

Happy to fix them in another PR when those files actually get touched.

@benhalpern
Copy link
Contributor

Awesome. Will give this full attention tomorrow @nickytonline. I agree with the assessment on linting. Outside of this scope.

}

totalTimeWaiting += waitTime;
setTimeout(waitingOnUserData, waitTime);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous implementation was using setInterval which could have bogged things down as setInterval just fires after n ms. regardless of whether or not what's in it is completed. With setTimeout things can run within it and once they're complete it can be called again. Having said that, this still doesn't seem like the best approach, but the current implementation is looking for DOM attributes being updated.

MutationObserver is an option as you can configure it to only listen for specific attributes' changes, but I think there is probably a better approach than setting these values on DOM attributes. However, since this PR was initally just to rename and move some files, it seems out of scope of this PR.

@@ -0,0 +1,109 @@
import { getUserDataAndCsrfToken } from '../util';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a note that these tests won't appear in the coverage report for the moment. As soon as the chat folder is within the src folder, they'll appear in coverage reports. This will happen in another PR.

Copy link
Contributor

@benhalpern benhalpern left a comment

Choose a reason for hiding this comment

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

This all looks good to me, but @maestromac can you give it a once-over?

}

function renderPage() {
import('../src/Onboarding')
Copy link
Contributor

Choose a reason for hiding this comment

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

I do. I'm also excited to improve on several fronts here.


return permission === 'default' ? 'waiting-permission' : permission;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah.

@maestromac maestromac merged commit 24621b0 into forem:master Aug 29, 2018
@nickytonline nickytonline deleted the task/pack-file-restructure branch April 9, 2019 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants