Skip to content

Commit

Permalink
fix(mobile): remove useless debug message
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Mar 20, 2019
1 parent c3aea71 commit 99449b0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
Expand Up @@ -60,7 +60,6 @@ class TabBarIconBase extends Component {
const { queryVariables } = this.state

queries.EventUnseen.fetch(queryVariables).then((e) => {
console.log('e', e)
this.setState({
stored: e.reduce((acc, val) => {
if (acc.indexOf(val.conversationId) === -1) {
Expand All @@ -70,7 +69,6 @@ class TabBarIconBase extends Component {
}, []),
})
})
console.log(queryVariables)
this.subscriber = subscriptions.commitLogStream.subscribe({
updater: this.updateBadge,
})
Expand All @@ -83,7 +81,7 @@ class TabBarIconBase extends Component {
}

updateBadge = (store, data) => {
const [operation, entity] = [data.CommitLogStream.operation, data.CommitLogStream.entity.event]
const [entity] = [data.CommitLogStream.entity.event]
const {
stored,
queryVariables: {
Expand All @@ -93,10 +91,8 @@ class TabBarIconBase extends Component {
},
} = this.state

if (entity && entity.kind === kind) {
console.log('operation', kind, operation, entity.seenAt === null, stored.indexOf(entity.conversationId))
if (entity && entity.kind === kind && entity.direction === 1) {
if (entity.seenAt === null && stored.indexOf(entity.conversationId) === -1) {
console.log('la', entity)
this.setState({
stored: [
...stored,
Expand Down Expand Up @@ -136,7 +132,7 @@ class TabBarIconBase extends Component {
const {
stored,
} = this.state
console.log('stored', stored)

context.relay = context.environment
let iconName = {
contacts: 'users',
Expand Down
20 changes: 13 additions & 7 deletions client/react-native/common/components/Screens/Chats/Detail.js
Expand Up @@ -38,15 +38,21 @@ const textStyles = StyleSheet.flatten([Markdown.styles, {
},
}])

class Message extends React.PureComponent {
class Message extends React.Component {
static contextType = RelayContext

messageSeen = async () => {
if (this.props.data.seenAt === null) {
await this.props.context.mutations.eventSeen({
id: this.props.data.id,
})
messageSeen = () => {
this.props.context.mutations.eventSeen({
id: this.props.data.id,
})
}

shouldComponentUpdate (nextProps, nextState) {
const { data: { seenAt } } = this.props
if (seenAt !== nextProps.data.seenAt) {
return false
}
return true
}

render () {
Expand All @@ -63,7 +69,7 @@ class Message extends React.PureComponent {
const isOneToOne = conversation.members.length <= 2

// TODO: implement message seen
if (new Date(this.props.data.seenAt).getTime() <= 0) {
if (this.props.data.seenAt === null) {
this.messageSeen()
}
return (
Expand Down
10 changes: 5 additions & 5 deletions client/react-native/common/components/Screens/Chats/List.js
Expand Up @@ -71,7 +71,6 @@ const ItemBase = fragments.Conversation(
onlyWithoutSeenAt: 1,
},
])).then((e) => {
console.log(e)
this.setState({
unread: e.map((val) => {
return val.id
Expand All @@ -89,12 +88,13 @@ const ItemBase = fragments.Conversation(
const { data: { id } } = this.props
let { unread } = this.state

if (entity && id === entity.conversationId && entity.kind === 302) {
// console.log('operation', operation, entity.seenAt === null, unread.indexOf(entity.id))
if (entity && entity.direction === 1 && id === entity.conversationId && entity.kind === 302) {
if (entity.seenAt === null && unread.indexOf(entity.id) === -1) {
unread.push(entity.id)
this.setState({
unread: unread,
unread: [
...unread,
entity.id,
],
})
} else if (entity.seenAt !== null && unread.indexOf(entity.id) !== -1) {
unread.splice(unread.indexOf(entity.id), 1)
Expand Down

0 comments on commit 99449b0

Please sign in to comment.