Skip to content

Commit

Permalink
Merge branch 'develop' into fix.better-message-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored and pranay414 committed Dec 12, 2018
2 parents 2e90a0a + ad37586 commit a220a46
Show file tree
Hide file tree
Showing 39 changed files with 556 additions and 1,023 deletions.
4 changes: 0 additions & 4 deletions app/actions/actionsTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ export const METEOR = createRequestTypes('METEOR_CONNECT', [...defaultTypes, 'DI
export const LOGOUT = 'LOGOUT'; // logout is always success
export const ACTIVE_USERS = createRequestTypes('ACTIVE_USERS', ['SET']);
export const ROLES = createRequestTypes('ROLES', ['SET']);
export const STARRED_MESSAGES = createRequestTypes('STARRED_MESSAGES', ['OPEN', 'READY', 'CLOSE', 'MESSAGES_RECEIVED', 'MESSAGE_UNSTARRED']);
export const PINNED_MESSAGES = createRequestTypes('PINNED_MESSAGES', ['OPEN', 'READY', 'CLOSE', 'MESSAGES_RECEIVED', 'MESSAGE_UNPINNED']);
export const MENTIONED_MESSAGES = createRequestTypes('MENTIONED_MESSAGES', ['OPEN', 'READY', 'CLOSE', 'MESSAGES_RECEIVED']);
export const SNIPPETED_MESSAGES = createRequestTypes('SNIPPETED_MESSAGES', ['OPEN', 'READY', 'CLOSE', 'MESSAGES_RECEIVED']);
export const ROOM_FILES = createRequestTypes('ROOM_FILES', ['OPEN', 'READY', 'CLOSE', 'MESSAGES_RECEIVED']);
export const DEEP_LINKING = createRequestTypes('DEEP_LINKING', ['OPEN']);
export const SORT_PREFERENCES = createRequestTypes('SORT_PREFERENCES', ['SET_ALL', 'SET']);
29 changes: 0 additions & 29 deletions app/actions/mentionedMessages.js

This file was deleted.

36 changes: 0 additions & 36 deletions app/actions/pinnedMessages.js

This file was deleted.

28 changes: 0 additions & 28 deletions app/actions/roomFiles.js

This file was deleted.

35 changes: 0 additions & 35 deletions app/actions/starredMessages.js

This file was deleted.

18 changes: 9 additions & 9 deletions app/containers/MessageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ export default class MessageActions extends React.Component {
});
}

setPermissions() {
const { room } = this.props;
const permissions = ['edit-message', 'delete-message', 'force-delete-message'];
const result = RocketChat.hasPermission(permissions, room.rid);
this.hasEditPermission = result[permissions[0]];
this.hasDeletePermission = result[permissions[1]];
this.hasForceDeletePermission = result[permissions[2]];
}

showActionSheet = () => {
ActionSheet.showActionSheetWithOptions({
options: this.options,
Expand All @@ -141,15 +150,6 @@ export default class MessageActions extends React.Component {
});
}

setPermissions() {
const { room } = this.props;
const permissions = ['edit-message', 'delete-message', 'force-delete-message'];
const result = RocketChat.hasPermission(permissions, room.rid);
this.hasEditPermission = result[permissions[0]];
this.hasDeletePermission = result[permissions[1]];
this.hasForceDeletePermission = result[permissions[2]];
}

getPermalink = async(message) => {
try {
return await RocketChat.getPermalink(message);
Expand Down
4 changes: 2 additions & 2 deletions app/containers/MessageBox/FilesActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import { Component } from 'react';
import PropTypes from 'prop-types';
import ActionSheet from 'react-native-action-sheet';

Expand Down Expand Up @@ -34,7 +34,7 @@ export default class FilesActions extends Component {
showActionSheet = () => {
ActionSheet.showActionSheetWithOptions({
options: this.options,
cancelButtonIndex: this.CANCEL_INDEX,
cancelButtonIndex: this.CANCEL_INDEX
}, (actionIndex) => {
this.handleActionPress(actionIndex);
});
Expand Down
26 changes: 13 additions & 13 deletions app/containers/MessageErrorActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ export default class MessageErrorActions extends React.Component {
actionMessage: PropTypes.object
};

handleResend = protectedFunction(() => {
const { actionMessage } = this.props;
RocketChat.resendMessage(actionMessage._id);
});

handleDelete = protectedFunction(() => {
const { actionMessage } = this.props;
database.write(() => {
const msg = database.objects('messages').filtered('_id = $0', actionMessage._id);
database.delete(msg);
});
})

// eslint-disable-next-line react/sort-comp
constructor(props) {
super(props);
Expand All @@ -47,19 +60,6 @@ export default class MessageErrorActions extends React.Component {
});
}

handleResend = protectedFunction(() => {
const { actionMessage } = this.props;
RocketChat.resendMessage(actionMessage._id);
});

handleDelete = protectedFunction(() => {
const { actionMessage } = this.props;
database.write(() => {
const msg = database.objects('messages').filtered('_id = $0', actionMessage._id);
database.delete(msg);
});
})

handleActionPress = (actionIndex) => {
const { errorActionsHide } = this.props;
switch (actionIndex) {
Expand Down
10 changes: 8 additions & 2 deletions app/containers/message/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const SYSTEM_MESSAGES = [
'room_changed_description',
'room_changed_announcement',
'room_changed_topic',
'room_changed_privacy'
'room_changed_privacy',
'message_snippeted'
];

const getInfoMessage = ({
Expand Down Expand Up @@ -76,6 +77,8 @@ const getInfoMessage = ({
return I18n.t('Room_changed_topic', { topic: msg, userBy: username });
} else if (type === 'room_changed_privacy') {
return I18n.t('Room_changed_privacy', { type: msg, userBy: username });
} else if (type === 'message_snippeted') {
return I18n.t('Created_snippet');
}
return '';
};
Expand Down Expand Up @@ -107,7 +110,10 @@ export default class Message extends PureComponent {
header: PropTypes.bool,
avatar: PropTypes.string,
alias: PropTypes.string,
ts: PropTypes.instanceOf(Date),
ts: PropTypes.oneOfType([
PropTypes.instanceOf(Date),
PropTypes.string
]),
edited: PropTypes.bool,
attachments: PropTypes.oneOfType([
PropTypes.array,
Expand Down
5 changes: 4 additions & 1 deletion app/containers/message/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export default class User extends React.PureComponent {
timeFormat: PropTypes.string.isRequired,
username: PropTypes.string,
alias: PropTypes.string,
ts: PropTypes.instanceOf(Date),
ts: PropTypes.oneOfType([
PropTypes.instanceOf(Date),
PropTypes.string
]),
temp: PropTypes.bool
}

Expand Down
2 changes: 2 additions & 0 deletions app/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default {
Copy_Permalink: 'Copy Permalink',
Create_account: 'Create an account',
Create_Channel: 'Create Channel',
Created_snippet: 'Created a snippet',
Create_a_new_workspace: 'Create a new workspace',
Create: 'Create',
Delete_Room_Warning: 'Deleting a room will delete all messages posted within the room. This cannot be undone.',
Expand Down Expand Up @@ -209,6 +210,7 @@ export default {
No_files: 'No files',
No_mentioned_messages: 'No mentioned messages',
No_pinned_messages: 'No pinned messages',
No_results_found: 'No results found',
No_snippeted_messages: 'No snippeted messages',
No_starred_messages: 'No starred messages',
No_announcement_provided: 'No announcement provided.',
Expand Down
2 changes: 2 additions & 0 deletions app/i18n/locales/pt-BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default {
Copy_Permalink: 'Copiar Link-Permanente',
Create_account: 'Criar conta',
Create_Channel: 'Criar Canal',
Created_snippet: 'Criou um snippet',
Create_a_new_workspace: 'Criar nova área de trabalho',
Create: 'Criar',
Delete_Room_Warning: 'A exclusão de uma sala irá apagar todas as mensagens postadas na sala. Isso não pode ser desfeito.',
Expand Down Expand Up @@ -212,6 +213,7 @@ export default {
No_files: 'Não há arquivos',
No_mentioned_messages: 'Não há menções',
No_pinned_messages: 'Não há mensagens fixadas',
No_results_found: 'Nenhum resultado encontrado',
No_snippeted_messages: 'Não há trechos de mensagens',
No_starred_messages: 'Não há mensagens favoritas',
No_announcement_provided: 'Sem anúncio.',
Expand Down
13 changes: 13 additions & 0 deletions app/lib/methods/loadMessagesForRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ import database from '../realm';
import log from '../../utils/log';

async function load({ rid: roomId, latest, t }) {
if (t === 'l') {
try {
const data = await SDK.driver.asyncCall('loadHistory', roomId, null, 50, latest);
if (!data || data.status === 'error') {
return [];
}
return data.messages;
} catch (error) {
console.log(error);
return [];
}
}

let params = { roomId, count: 50 };
if (latest) {
params = { ...params, latest: new Date(latest).toISOString() };
Expand Down
Loading

0 comments on commit a220a46

Please sign in to comment.