Skip to content

Commit

Permalink
feat: send mark as seen signal to core when displaying messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Louvigny authored and 90dy committed Dec 11, 2018
1 parent 59f641a commit d087adc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
34 changes: 20 additions & 14 deletions client/react-native/common/components/Screens/Chats/Detail.js
Expand Up @@ -17,14 +17,16 @@ class Message extends React.PureComponent {
const conversation = this.props.navigation.getParam('conversation')
const contactId = this.props.data.senderId
const isMyself =
conversation.members.find(m => m.contactId === contactId).contact.status ===
42
conversation.members.find(m => m.contactId === contactId).contact
.status === 42

if (isMyself || this.props.data.seenAt !== null) {
return
}

await this.props.screenProps.context.mutations.eventSeen({ eventId: this.props.data.id })
await this.props.screenProps.context.mutations.eventSeen({
eventId: this.props.data.id,
})
}

async componentDidUpdate (prevProps) {
Expand All @@ -39,8 +41,8 @@ class Message extends React.PureComponent {
const conversation = this.props.navigation.getParam('conversation')
const contactId = this.props.data.senderId
const isMyself =
conversation.members.find(m => m.contactId === contactId).contact.status ===
42
conversation.members.find(m => m.contactId === contactId).contact
.status === 42

const { data } = this.props

Expand Down Expand Up @@ -78,13 +80,12 @@ class Message extends React.PureComponent {
[isMyself ? 'left' : 'right']: 42,
}}
>
{new Date(data.createdAt).toTimeString()}
{' '}
{isMyself
? <Icon name={data.ackedAt ? 'check-circle' : 'circle'} />
: null}
{' '}
<Icon name={data.seenAt ? 'eye' : 'eye-off'} /> {/* TODO: used for debugging, remove me */}
{new Date(data.createdAt).toTimeString()}{' '}
{isMyself ? (
<Icon name={data.ackedAt ? 'check-circle' : 'circle'} />
) : null}{' '}
<Icon name={data.seenAt ? 'eye' : 'eye-off'} />{' '}
{/* TODO: used for debugging, remove me */}
</Text>
</Flex.Rows>
)
Expand Down Expand Up @@ -222,8 +223,13 @@ export default class Detail extends PureComponent {
subscriptions={[subscriptions.conversationNewMessage]}
fragment={fragments.EventList}
alias='EventList'
renderItem={props => <MessageContainer {...props} navigation={navigation}
screenProps={this.props.screenProps} />}
renderItem={props => (
<MessageContainer
{...props}
navigation={navigation}
screenProps={this.props.screenProps}
/>
)}
inverted
style={{ paddingTop: 48 }}
/>
Expand Down
2 changes: 1 addition & 1 deletion core/go.mod
Expand Up @@ -135,7 +135,7 @@ require (
github.com/uber-go/atomic v1.3.2 // indirect
github.com/uber/jaeger-client-go v2.15.0+incompatible
github.com/uber/jaeger-lib v1.5.0 // indirect
github.com/vektah/gqlparser v0.0.0-20181002002754-f119686bf1d4
github.com/vektah/gqlparser v0.0.0-20181002002754-f119686bf1d4 // indirect
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
Expand Down

0 comments on commit d087adc

Please sign in to comment.