This commit is contained in:
Diego Mello 2017-11-29 16:17:04 -02:00
parent 6eeff4d32c
commit 490ddfd57b
3 changed files with 36 additions and 2 deletions

View File

@ -51,6 +51,7 @@ export default class Message extends React.Component {
onLongPress() {
const { item } = this.props;
console.warn(item)
this.props.actionsShow(JSON.parse(JSON.stringify(item)));
}
@ -86,6 +87,23 @@ export default class Message extends React.Component {
);
}
renderMetaUrl() {
if (this.props.item.urls.length === 0) {
return null;
}
return (
<View style={{ flex: 1, height: 80, flexDirection: 'row', alignItems: 'center' }}>
<View style={{ borderWidth: 2, borderRadius: 4, borderColor: '#a0a0a0', height: '100%', marginRight: 5 }} />
<View style={{ height: 80, width: 80, backgroundColor: '#a0a0a0', borderRadius: 6 }} />
<View style={{ flex: 1, height: '100%', flexDirection: 'column', padding: 4, justifyContent: 'flex-start', alignItems: 'flex-start' }}>
<Text style={{ fontWeight: 'bold', fontSize: 16, color: '#a0a0a0' }}>Title</Text>
<Text>Description</Text>
</View>
</View>
);
}
render() {
const {
item, message, editing
@ -120,7 +138,8 @@ export default class Message extends React.Component {
baseUrl={this.props.baseUrl}
/>
{this.attachments()}
{this.renderMessageContent(item)}
{this.renderMessageContent()}
{this.renderMetaUrl()}
</View>
</TouchableOpacity>
);

View File

@ -115,6 +115,17 @@ const attachment = {
}
};
// const url = {
// name: 'url',
// properties: {
// url: { type: 'string', optional: true },
// title: { type: 'string', optional: true },
// description: { type: 'string', optional: true },
// author: { type: 'string', optional: true }
// }
// };
const messagesEditedBySchema = {
name: 'messagesEditedBy',
properties: {
@ -141,6 +152,7 @@ const messagesSchema = {
groupable: { type: 'bool', optional: true },
avatar: { type: 'string', optional: true },
attachments: { type: 'list', objectType: 'attachment' },
// urls: { type: 'list', objectType: 'url' },
_updatedAt: { type: 'date', optional: true },
temp: { type: 'bool', optional: true },
pinned: { type: 'bool', optional: true },
@ -163,7 +175,8 @@ const realm = new Realm({
attachment,
messagesEditedBySchema,
permissionsSchema,
permissionsRolesSchema
permissionsRolesSchema,
// url
],
deleteRealmIfMigrationNeeded: true
});

View File

@ -256,11 +256,13 @@ const RocketChat = {
return reject(err);
}
if (data && data.messages.length) {
console.log(data)
realm.write(() => {
data.messages.forEach((message) => {
message.temp = false;
message._server = { id: reduxStore.getState().server.server };
message.attachments = message.attachments || [];
message.urls = message.urls || [];
// write('messages', message);
message.starred = !!message.starred;
realm.create('messages', message, true);