Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
- Loading branch information
Showing
37 changed files
with
749 additions
and
511 deletions.
There are no files selected for viewing
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,6 @@ | ||
import pbjs from 'protobufjs/light' | ||
import jsonDescriptor from './message.pb.json' | ||
|
||
const root = pbjs.Root.fromJSON(jsonDescriptor) | ||
export const Message = root.lookup('berty.entity.Message') | ||
export default Message |
47 changes: 47 additions & 0 deletions
47
client/react-native/app/common/helpers/entity/conversation.js
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,47 @@ | ||
import { BertyEntityContactInputStatus } from '../../enums.gen' | ||
import tDate from '../timestampDate' | ||
|
||
export const getTitle = ({ title, members }) => | ||
(title && title !== '' && title) || | ||
(members && | ||
members | ||
.filter(m => m.contact && m.contact.status !== 42) | ||
.map((m, index) => { | ||
const displayName = | ||
m.contact && | ||
(m.contact.overrideDisplayName || m.contact.displayName || '?????') | ||
const before = | ||
index === 0 ? '' : index === members.length - 1 ? ' and ' : ', ' | ||
return `${before}${displayName}` | ||
}) | ||
.join('')) || | ||
'No name' | ||
|
||
export const isReadByMe = ({ wroteAt, members }) => { | ||
const myself = members.find( | ||
_ => _.contact && _.contact.status === BertyEntityContactInputStatus.Myself | ||
) | ||
if (myself == null) { | ||
return true | ||
} | ||
return tDate(myself.readAt).getTime() >= tDate(wroteAt).getTime() | ||
} | ||
|
||
export const isMessageReadByMe = ({ members }, { createdAt }) => { | ||
const myself = members.find( | ||
_ => _.contact && _.contact.status === BertyEntityContactInputStatus.Myself | ||
) | ||
if (myself == null) { | ||
return true | ||
} | ||
return tDate(myself.readAt).getTime() >= tDate(createdAt).getTime() | ||
} | ||
|
||
export const isReadByOthers = message => | ||
message.dispatches && | ||
message.dispatches.some(_ => tDate(_.ackedAt).getTime() > 0) | ||
|
||
export const messageHasError = message => | ||
message.dispatches.some( | ||
_ => _.sendErrorMessage != null && _.sendErrorMessage !== '' | ||
) |
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 @@ | ||
export * as conversation from './conversation' |
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,10 @@ | ||
export const timestampDate = timestamp => { | ||
return new Date( | ||
timestamp | ||
? timestamp.seconds * 1000 + | ||
(timestamp.nanos ? Math.round(timestamp.nanos / 1000000) : 0) | ||
: 0 | ||
) | ||
} | ||
|
||
export default timestampDate |
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
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
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
Oops, something went wrong.