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

Style conflict resolution page #199

Merged
merged 7 commits into from
Mar 28, 2017
Merged

Conversation

Tyler-Brenneman
Copy link
Collaborator

@Tyler-Brenneman Tyler-Brenneman commented Mar 27, 2017

Closes #148

Styles the conflict resolution page.

Handled sync cases:

  • Flagging deleted remote deck -> add to inaccessibleDecks
  • Flagging deleted private deck -> delete deck
  • Editing deleted private deck -> sync conflict

image

image

Copy link
Owner

@mattyu007 mattyu007 left a comment

Choose a reason for hiding this comment

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

Looking good.

// check if any other changes need to be synced
for (let key in change) {
if((key === 'cards' && change.cards.length) || (change[key] != serverDeck[key] && !key.match("^(?:cards|uuid|action)$"))) {
if((key === 'cards' && change.cards.length) || (change[key] != updatedDeck[key] && !key.match("^(?:cards|uuid|action)$"))) {
serverDeck = await LibraryApi.editDeck({
Copy link
Owner

Choose a reason for hiding this comment

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

Should this be updatedDeck = ?


//TODO: issue #146: style this page
type Conflict = {
Copy link
Owner

Choose a reason for hiding this comment

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

Import this from actions/library instead?

<Text style={this.props.disabled ? styles.textDisabled : styles.text}>
{this.props.text}
</Text>
<View>
Copy link
Owner

Choose a reason for hiding this comment

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

This view needs flex: 1 and the icon needs flex: 0 for the text to wrap and not push the icon off the screen.

Copy link
Owner

Choose a reason for hiding this comment

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

Also, minor nitpick: I think the Android paddingVertical in container can be reduced to 8, the rows are spaced really far apart right now.

<Text style={this.props.disabled ? styles.textDisabled : styles.text}>
{this.props.text}
</Text>
<Text style={styles.textSecondary}>
Copy link
Owner

Choose a reason for hiding this comment

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

You have to only render this conditionally based on whether this.props.subText is specified, otherwise layouts with just primary text are shifted.

_internetAlert = () => {
Alert.alert (
Platform.OS === "android" ? 'Failed to resolve conflicts' : 'Failed to Resolve Conflicts',
'Check your Internet connection and try again.')
Copy link
Owner

Choose a reason for hiding this comment

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

Can just pull the recoveryMessage based on changes in #207.

? 'Keep changes from "' + conflict.serverDeck.last_update_device + '"'
: 'Keep server copy'
} else {
serverText = 'Keep deleted server change'
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe "Delete this deck" and make the subtext "Deleted on another device" or something?

if (interval > 1) {
return interval + " minutes";
}
return Math.floor(seconds) + " seconds";
Copy link
Owner

Choose a reason for hiding this comment

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

I'd actually call this "just now" so the time is a little fuzzier.

<ListView
onLayout={this.on_layout}
key={this.state.conflicts}
Copy link
Owner

Choose a reason for hiding this comment

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

Does this need a key?

else
decks[deckIndex] = serverDeck
} else if (updatedDeck.deleted) {
decks.splice(deckIndex,1)
Copy link
Owner

Choose a reason for hiding this comment

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

Isn't this already handled by the inaccessibleDecks stuff in LOADED_LIBRARY?

return Math.floor(seconds) + " seconds";
}

_renderRow = (conflict) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Flow type?

@Tyler-Brenneman Tyler-Brenneman changed the title [WIP] Style conflict resolution page Style conflict resolution page Mar 28, 2017
icon: CueIcons.cancel,
onPress: () => { this.props.navigator.pop() }
}
}

_getRightItems = () => {
if (this.state.conflicts && !this.state.conflicts.find(c => c.useServerDeck==undefined)) {
if (this.state.conflicts && !this.state.conflicts.find(c => c.useServerDeck==null)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Are we using null or undefined? This check worked anyway since:

null == undefined  // true
null != undefined  // false
null === undefined // false
null !== undefined // true

I'd use === or typeof obj === 'undefined' for all checks which involve undefined values.

Copy link
Owner

Choose a reason for hiding this comment

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

Also: check if !this.state.loading here.

if (interval >= 1) {
return interval + ' minute' + (interval > 1 ? 's' : '') + ' ago'
}
return ' just now'
Copy link
Owner

Choose a reason for hiding this comment

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

There's an extra leading space here?

@@ -127,7 +127,8 @@ class LibraryHome extends React.Component {
[
{text: 'Remove', style: 'destructive'},
{text: 'Copy', onPress: () => this.props.onCopyDeck(deck)},
]
],
{ cancelable: false }
Copy link
Owner

Choose a reason for hiding this comment

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

Nice catch. 👍


let content
if (this.state.loading) {
content = <ActivityIndicator/>
Copy link
Owner

Choose a reason for hiding this comment

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

This needs style={{flex: 1}} to be centred.

label: 'Use local copy',
value: false
}
{ label: 'Use server copy', value: true },
Copy link
Owner

Choose a reason for hiding this comment

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

These aren't being used anymore, right?

<View style={{flex: 1}}>
<Text style={styles.headerText}>{headerText}</Text>
<ListView
dataSource={this.state.dataSource}
Copy link
Owner

Choose a reason for hiding this comment

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

Can you add removeClippedSubviews={false} to the ListView (and also to the ListViews in LibraryListView and CardListView)? There's a long-standing RN bug where if a ListView is updated off-screen, when it reappears on the screen, the contents don't appear until the list is scrolled facebook/react-native#8607 In this case, the list can be rendered before the view is animated onto the screen, so the ListView is empty until it is scrolled.

@Tyler-Brenneman
Copy link
Collaborator Author

Tyler-Brenneman commented Mar 28, 2017

@mattyu007 Updated. Set removeClippedSubviews={false} only when platform is ios

Copy link
Owner

@mattyu007 mattyu007 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. We should try another stress test to make sure scroll performance on iOS doesn't regress tremendously because of removeClippedSubviews.

@mattyu007
Copy link
Owner

Closes #200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants