-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Begin porting the web POC to react native #10
Merged
Merged
Changes from 14 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
bef1ed1
Remove all async and clean up pages
tgolen 7a8f83b
Fix an error with merge
tgolen d9cb5b3
Add some style to the header
tgolen f55a6d4
Add styles and display a header
tgolen 07db03a
Add the personal details action
tgolen 4496f10
Add personal details to the header
tgolen ae9f529
WIP on direct binding
tgolen b0a1575
Implement direct binding
tgolen f9a094a
Fix unsubscribing
tgolen 0366c4f
Fix infinite session redirect
tgolen f153fb5
Build an HOC for subscribing the state to the store
tgolen 307dfd2
Add a little more comment
tgolen e31528b
Add initial sidebar and main views and lay them out
tgolen a5cbde6
List reports in the sidebar
tgolen 2490b9c
Update src/page/HomePage/HeaderView.js
tgolen a02d992
Update src/style/StyleSheet.js
tgolen a3de49e
Fix typo
tgolen 743db5f
Merge branch 'tgolen-port-webpoc' of https://github.com/AndrewGable/R…
tgolen 2f8016b
Use Link instead of NavLink
tgolen 67ee483
Use a simple subscription ID
tgolen e42283d
Rename subscribeToState to bind
tgolen b2a9b7e
Trigger key changed after storage is set
tgolen 8df561f
Move the sidebar link into it's own component
tgolen 74d5455
remove calc() from styles
tgolen da8177c
Show the list of report names as decent links
tgolen f2ed6a8
Remvoe subscribe and unsubscribe for now
tgolen 04b5751
Only create regex object when binding
tgolen cbc7368
Rename unsubscribeFromState to unbind
tgolen 9b8a3b8
Reorder the params for binding
tgolen 9a26bc3
Remove persistent storage
tgolen af2333f
Use merge in as many places as possible
tgolen cad8207
Remove weird code
tgolen 2130a64
Improve the styles in the sidebar
tgolen 99e3a73
Add a report view and show the report name
tgolen 3b8fcaf
Show the report name on the header
tgolen 1843eb7
Load the report history when looking at a report
tgolen fb063ce
Rename the HOC to WithStore
tgolen 732ac89
Do better at prefilling data from the right keys
tgolen c9e45c1
Improve the signature of bind
tgolen 545be1f
Add a view for displaying history items
tgolen 1807767
Add some more views for displaying history items
tgolen 22aa79e
Display history fragments
tgolen c8384ab
Better comment
tgolen a813cde
Fix a semi-broken home page
tgolen 798135c
Apply mobile fixes
AndrewGable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const CONST = { | ||
CLOUDFRONT_URL: 'https://d2k5nsl2zxldvw.cloudfront.net', | ||
}; | ||
|
||
export default CONST; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* This is a higher order component that provides the ability to map a state property directly to | ||
* something in the store. That way, as soon as the store changes, the state will be set and the view | ||
* will automatically change to reflect the new data. | ||
*/ | ||
import React from 'react'; | ||
import _ from 'underscore'; | ||
import * as Store from '../store/Store'; | ||
|
||
export default function (mapStoreToStates) { | ||
return WrappedComponent => class WithStoreSubscribeToState extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.subscribedEventGuids = []; | ||
|
||
// Initialize the state with each of our property names | ||
this.state = _.reduce(_.keys(mapStoreToStates), (finalResult, propertyName) => ({ | ||
...finalResult, | ||
[propertyName]: null, | ||
}), {}); | ||
} | ||
|
||
componentDidMount() { | ||
this.subscribedEventGuids = _.reduce(mapStoreToStates, (finalResult, mapStoreToState, propertyName) => { | ||
const {key, path} = mapStoreToState; | ||
return [ | ||
...finalResult, | ||
Store.subscribeToState(key, propertyName, path, null, this.wrappedComponent), | ||
]; | ||
}, []); | ||
|
||
_.each(mapStoreToStates, (mapStoreToState) => { | ||
if (mapStoreToState.loader) { | ||
mapStoreToState.loader(...mapStoreToState.loaderParams || []); | ||
} | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
_.each(this.subscribedEventGuids, Store.unsubscribeFromState); | ||
} | ||
|
||
render() { | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return <WrappedComponent {...this.props} {...this.state} ref={el => this.wrappedComponent = el} />; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mobile doesn't play well with this, it seems to use
window
quite a bit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dang, this was supposed to be compatible :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not an expert on this event, but could we use
AppState
instead? It is supported by RN and RN4W out of the box: https://github.com/necolas/react-native-web#modulesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested this and yes it does change to
inactive
when the tab is changed, then back toactive
when it comes back. This sounds like possibly we need to handle it using a native/web solution (likeRouter
).