Skip to content

Commit

Permalink
General RN fixes - chat dumb placeholders - conversation list refactor (
Browse files Browse the repository at this point in the history
#5812)

* added watchman config. added dummy chat component files. fix text eating taps. rename yourekey compnent. add simulator flag to native. add notification listeners

* dumb chat cross platform

* conversation list refactor

* undo whitespace

* lint fixes

* plumb through backgroundColor

* Conversation list mobile (#5813)

* usernames working

* bottom line working

* WIP

* fixup merge

* fix overflow on row bottom

* pr fixes

* min width on convo list

* WIP

* lineClamp messes up truncation for some reason
  • Loading branch information
chrisnojima committed Feb 14, 2017
1 parent 466bd68 commit 700a5df
Show file tree
Hide file tree
Showing 33 changed files with 575 additions and 209 deletions.
1 change: 1 addition & 0 deletions shared/.watchmanconfig
@@ -0,0 +1 @@
{}
5 changes: 4 additions & 1 deletion shared/actions/chat.js
Expand Up @@ -847,6 +847,9 @@ function * _setupChatHandlers (): SagaGenerator<any, any> {
const inboxSelector = (state: TypedState, conversationIDKey) => state.chat.get('inbox')

function * selectValidConversation () {
if (isMobile) {
return // Mobile doens't auto select a conversation
}
const inbox = yield select(inboxSelector)
if (inbox.count()) {
const conversationIDKey = yield select(_selectedSelector)
Expand Down Expand Up @@ -925,7 +928,7 @@ function * _loadInbox (action: ?LoadInbox): SagaGenerator<any, any> {
}
// find it
} else if (incoming.chatInboxFailed) {
console.warn('ignoring chatInboxFailed', incoming.chatInboxFailed)
console.log('ignoring chatInboxFailed', incoming.chatInboxFailed)
incoming.chatInboxFailed.response.result()
const error = incoming.chatInboxFailed.params.error
const conversationIDKey = conversationIDToKey(incoming.chatInboxFailed.params.convID)
Expand Down
3 changes: 3 additions & 0 deletions shared/chat/conversation/banner.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
3 changes: 3 additions & 0 deletions shared/chat/conversation/edit-popup.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
3 changes: 3 additions & 0 deletions shared/chat/conversation/header.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
3 changes: 3 additions & 0 deletions shared/chat/conversation/input.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
3 changes: 3 additions & 0 deletions shared/chat/conversation/list.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
File renamed without changes.
3 changes: 3 additions & 0 deletions shared/chat/conversation/messages/index.js.flow
@@ -0,0 +1,3 @@
// @flow
const factory = (options: any) => {};
export default factory
31 changes: 31 additions & 0 deletions shared/chat/conversation/messages/index.native.js
@@ -0,0 +1,31 @@
// @flow
import * as ChatConstants from '../../../constants/chat'
import React from 'react'
import {Box} from '../../../common-adapters'

import type {Message, AttachmentMessage, ServerMessage, MetaDataMap, FollowingMap, OutboxIDKey} from '../../../constants/chat'

type Options = {
message: Message,
includeHeader: boolean,
key: string,
isFirstNewMessage: boolean,
style: Object,
isScrolling: boolean,
onAction: (message: ServerMessage, event: any) => void,
isSelected: boolean,
onLoadAttachment: (messageID: ChatConstants.MessageID, filename: string) => void,
onOpenInFileUI: (path: string) => void,
onOpenInPopup: (message: AttachmentMessage) => void,
onRetry: (outboxID: OutboxIDKey) => void,
onRetryAttachment: () => void,
you: string,
metaDataMap: MetaDataMap,
followingMap: FollowingMap,
}

const factory = (options: Options) => {
return <Box key={options.key} style={options.style} />
}

export default factory
3 changes: 3 additions & 0 deletions shared/chat/conversation/no-conversation.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
11 changes: 11 additions & 0 deletions shared/chat/conversation/participant-rekey.js.flow
@@ -0,0 +1,11 @@
// @flow
import {Component} from 'react'

import type {RekeyInfo} from '../../constants/chat'

export type Props = {
rekeyInfo: RekeyInfo,
onShowProfile: (username: string) => void,
}

export default class ParticipantRekey extends Component<void, Props, void> { }
3 changes: 3 additions & 0 deletions shared/chat/conversation/participant-rekey.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
3 changes: 3 additions & 0 deletions shared/chat/conversation/side-panel/index.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
4 changes: 2 additions & 2 deletions shared/chat/conversation/you-rekey.desktop.js
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import {Box, Button, Text} from '../../common-adapters'
import {globalColors, globalStyles} from '../../styles'

const ParticipantRekey = ({onRekey}: {onRekey: () => void}) => {
const YouRekey = ({onRekey}: {onRekey: () => void}) => {
return (
<Box style={containerStyle}>
<Box style={{...globalStyles.flexBoxRow, backgroundColor: globalColors.red, justifyContent: 'center'}}>
Expand All @@ -24,4 +24,4 @@ const containerStyle = {
justifyContent: 'flex-start',
}

export default ParticipantRekey
export default YouRekey
10 changes: 10 additions & 0 deletions shared/chat/conversation/you-rekey.js.flow
@@ -0,0 +1,10 @@
// @flow
import {Component} from 'react'

import type {RekeyInfo} from '../../constants/chat'

export type Props = {
onRekey: () => void
}

export default class YouRekey extends Component<void, Props, void> { }
3 changes: 3 additions & 0 deletions shared/chat/conversation/you-rekey.native.js
@@ -0,0 +1,3 @@
// @flow
const TODO = () => null
export default TODO
58 changes: 56 additions & 2 deletions shared/chat/conversations-list/container.js
@@ -1,8 +1,11 @@
// @flow
import React, {Component} from 'react'
import ConversationList from './index'
import React, {Component} from 'react'
import {connect} from 'react-redux'
import {formatTimeForConversationList} from '../../util/timestamp'
import {globalColors} from '../../styles'
import {loadInbox, selectConversation, newChat} from '../../actions/chat'
import {participantFilter} from '../../constants/chat'

import type {ConversationIDKey} from '../../constants/chat'
import type {TypedState} from '../../constants/reducer'
Expand All @@ -13,7 +16,54 @@ class ConversationListContainer extends Component {
}

render () {
return <ConversationList {...this.props} />
const rows = this.props.inbox.map(conversation => {
const conversationIDKey: ConversationIDKey = conversation.get('conversationIDKey')
const unreadCount = this.props.conversationUnreadCounts.get(conversationIDKey)
const participants = participantFilter(conversation.get('participants'), this.props.you)
const isSelected = this.props.selectedConversation === conversationIDKey
const isMuted = conversation.get('muted')
const rekeyInfo = this.props.selectedConversation && this.props.rekeyInfos.get(conversationIDKey)
const timestamp = formatTimeForConversationList(conversation.get('time'), this.props.nowOverride)
const snippet = conversation.get('snippet')
const onSelectConversation = this.props.onSelectConversation

// Derived props
const youNeedToRekey = rekeyInfo && !rekeyInfo.get('rekeyParticipants').count() && rekeyInfo.get('youCanRekey')
const participantNeedToRekey = rekeyInfo && !!rekeyInfo.get('rekeyParticipants').count()
const hasUnread = !!unreadCount
const subColor = isSelected ? globalColors.black_40 : hasUnread ? globalColors.white : globalColors.blue3_40
const showBold = !isSelected && hasUnread
const backgroundColor = isSelected ? globalColors.white : hasUnread ? globalColors.darkBlue : globalColors.darkBlue4
const usernameColor = isSelected ? globalColors.black_75 : hasUnread ? globalColors.white : globalColors.blue3_60
const commaColor = isSelected ? globalColors.black_60 : hasUnread ? globalColors.white_75 : globalColors.blue3_40

return {
backgroundColor,
commaColor,
conversationIDKey,
hasUnread,
isMuted,
isSelected,
onSelectConversation,
participantNeedToRekey,
participants,
rekeyInfo,
showBold,
snippet,
subColor,
timestamp,
unreadCount,
usernameColor,
youNeedToRekey,
}
})

return <ConversationList
children={this.props.children}
onNewChat={this.props.onNewChat}
onSelectConversation={this.props.onSelectConversation}
rows={rows}
/>
}
}

Expand All @@ -31,3 +81,7 @@ export default connect(
onSelectConversation: (key: ConversationIDKey) => dispatch(selectConversation(key, true)),
})
)(ConversationListContainer)

export {
ConversationListContainer,
}

0 comments on commit 700a5df

Please sign in to comment.