[FIX] Small fixes on UIKit (#1709)
This commit is contained in:
parent
1d79746eff
commit
3a87872415
|
@ -4,6 +4,8 @@ export function notificationReceived(params) {
|
||||||
return {
|
return {
|
||||||
type: NOTIFICATION.RECEIVED,
|
type: NOTIFICATION.RECEIVED,
|
||||||
payload: {
|
payload: {
|
||||||
|
title: params.title,
|
||||||
|
avatar: params.avatar,
|
||||||
message: params.text,
|
message: params.text,
|
||||||
payload: params.payload
|
payload: params.payload
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ const Items = ({
|
||||||
<FlatList
|
<FlatList
|
||||||
data={items}
|
data={items}
|
||||||
style={[styles.items, { backgroundColor: themes[theme].backgroundColor }]}
|
style={[styles.items, { backgroundColor: themes[theme].backgroundColor }]}
|
||||||
contentContainerStyle={{ backgroundColor: themes[theme].backgroundColor }}
|
contentContainerStyle={[styles.itemContent, { backgroundColor: themes[theme].backgroundColor }]}
|
||||||
keyboardShouldPersistTaps='always'
|
keyboardShouldPersistTaps='always'
|
||||||
ItemSeparatorComponent={() => <Separator theme={theme} />}
|
ItemSeparatorComponent={() => <Separator theme={theme} />}
|
||||||
keyExtractor={keyExtractor}
|
keyExtractor={keyExtractor}
|
||||||
|
|
|
@ -50,8 +50,11 @@ export default StyleSheet.create({
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: 16
|
right: 16
|
||||||
},
|
},
|
||||||
|
itemContent: {
|
||||||
|
paddingBottom: 36
|
||||||
|
},
|
||||||
items: {
|
items: {
|
||||||
height: 200
|
height: 226
|
||||||
},
|
},
|
||||||
chips: {
|
chips: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
|
|
@ -82,7 +82,7 @@ export const Overflow = ({
|
||||||
hitSlop={BUTTON_HIT_SLOP}
|
hitSlop={BUTTON_HIT_SLOP}
|
||||||
style={styles.menu}
|
style={styles.menu}
|
||||||
>
|
>
|
||||||
{!loading ? <CustomIcon size={18} name='menu' /> : <ActivityIndicator style={styles.loading} />}
|
{!loading ? <CustomIcon size={18} name='menu' color={themes[theme].bodyText} /> : <ActivityIndicator style={styles.loading} theme={theme} />}
|
||||||
</Touchable>
|
</Touchable>
|
||||||
<Popover
|
<Popover
|
||||||
isVisible={show}
|
isVisible={show}
|
||||||
|
|
|
@ -38,7 +38,7 @@ const Table = React.memo(({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onPress = () => Navigation.navigate('TableView', { renderRows, tableWidth: getTableWidth() });
|
const onPress = () => Navigation.navigate('MarkdownTableView', { renderRows, tableWidth: getTableWidth() });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity onPress={onPress}>
|
<TouchableOpacity onPress={onPress}>
|
||||||
|
|
|
@ -133,7 +133,11 @@ export function triggerAction({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { type: interactionType, ...data } = await result.json();
|
const { type: interactionType, ...data } = await result.json();
|
||||||
return resolve(handlePayloadUserInteraction(interactionType, data));
|
handlePayloadUserInteraction(interactionType, data);
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// modal.close has no body, so result.json will fail
|
// modal.close has no body, so result.json will fail
|
||||||
// but it returns ok status
|
// but it returns ok status
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { roomsRequest } from '../../../actions/rooms';
|
||||||
import { notificationReceived } from '../../../actions/notification';
|
import { notificationReceived } from '../../../actions/notification';
|
||||||
import { handlePayloadUserInteraction } from '../actions';
|
import { handlePayloadUserInteraction } from '../actions';
|
||||||
import buildMessage from '../helpers/buildMessage';
|
import buildMessage from '../helpers/buildMessage';
|
||||||
|
import RocketChat from '../../rocketchat';
|
||||||
|
|
||||||
const removeListener = listener => listener.stop();
|
const removeListener = listener => listener.stop();
|
||||||
|
|
||||||
|
@ -275,6 +276,15 @@ export default function subscribeRooms() {
|
||||||
}
|
}
|
||||||
if (/notification/.test(ev)) {
|
if (/notification/.test(ev)) {
|
||||||
const [notification] = ddpMessage.fields.args;
|
const [notification] = ddpMessage.fields.args;
|
||||||
|
try {
|
||||||
|
const { payload: { rid } } = notification;
|
||||||
|
const subCollection = db.collections.get('subscriptions');
|
||||||
|
const sub = await subCollection.find(rid);
|
||||||
|
notification.title = RocketChat.getRoomTitle(sub);
|
||||||
|
notification.avatar = RocketChat.getRoomAvatar(sub);
|
||||||
|
} catch (e) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
store.dispatch(notificationReceived(notification));
|
store.dispatch(notificationReceived(notification));
|
||||||
}
|
}
|
||||||
if (/uiInteraction/.test(ev)) {
|
if (/uiInteraction/.test(ev)) {
|
||||||
|
|
|
@ -1131,6 +1131,9 @@ const RocketChat = {
|
||||||
const { UI_Use_Real_Name: useRealName } = reduxStore.getState().settings;
|
const { UI_Use_Real_Name: useRealName } = reduxStore.getState().settings;
|
||||||
return ((room.prid || useRealName) && room.fname) || room.name;
|
return ((room.prid || useRealName) && room.fname) || room.name;
|
||||||
},
|
},
|
||||||
|
getRoomAvatar(room) {
|
||||||
|
return room.prid ? room.fname : room.name;
|
||||||
|
},
|
||||||
|
|
||||||
findOrCreateInvite({ rid, days, maxUses }) {
|
findOrCreateInvite({ rid, days, maxUses }) {
|
||||||
// RC 2.4.0
|
// RC 2.4.0
|
||||||
|
|
|
@ -158,15 +158,18 @@ class NotificationBadge extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
goToRoom = async() => {
|
goToRoom = async() => {
|
||||||
const { notification: { payload }, navigation, baseUrl } = this.props;
|
const { notification, navigation, baseUrl } = this.props;
|
||||||
|
const { payload } = notification;
|
||||||
const { rid, type, prid } = payload;
|
const { rid, type, prid } = payload;
|
||||||
if (!rid) {
|
if (!rid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const name = type === 'd' ? payload.sender.username : payload.name;
|
const name = type === 'd' ? payload.sender.username : payload.name;
|
||||||
|
// if sub is not on local database, title will be null, so we use payload from notification
|
||||||
|
const { title = name } = notification;
|
||||||
await navigation.navigate('RoomsListView');
|
await navigation.navigate('RoomsListView');
|
||||||
navigation.navigate('RoomView', {
|
navigation.navigate('RoomView', {
|
||||||
rid, name, t: type, prid, baseUrl
|
rid, name: title, t: type, prid, baseUrl
|
||||||
});
|
});
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
|
@ -178,6 +181,8 @@ class NotificationBadge extends React.Component {
|
||||||
const { message, payload } = notification;
|
const { message, payload } = notification;
|
||||||
const { type } = payload;
|
const { type } = payload;
|
||||||
const name = type === 'd' ? payload.sender.username : payload.name;
|
const name = type === 'd' ? payload.sender.username : payload.name;
|
||||||
|
// if sub is not on local database, title and avatar will be null, so we use payload from notification
|
||||||
|
const { title = name, avatar = name } = notification;
|
||||||
|
|
||||||
let top = 0;
|
let top = 0;
|
||||||
if (isIOS) {
|
if (isIOS) {
|
||||||
|
@ -211,9 +216,9 @@ class NotificationBadge extends React.Component {
|
||||||
background={Touchable.SelectableBackgroundBorderless()}
|
background={Touchable.SelectableBackgroundBorderless()}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<Avatar text={name} size={AVATAR_SIZE} type={type} baseUrl={baseUrl} style={styles.avatar} userId={userId} token={token} />
|
<Avatar text={avatar} size={AVATAR_SIZE} type={type} baseUrl={baseUrl} style={styles.avatar} userId={userId} token={token} />
|
||||||
<View style={styles.inner}>
|
<View style={styles.inner}>
|
||||||
<Text style={[styles.roomName, { color: themes[theme].titleText }]} numberOfLines={1}>{name}</Text>
|
<Text style={[styles.roomName, { color: themes[theme].titleText }]} numberOfLines={1}>{title}</Text>
|
||||||
<Text style={[styles.message, { color: themes[theme].titleText }]} numberOfLines={1}>{message}</Text>
|
<Text style={[styles.message, { color: themes[theme].titleText }]} numberOfLines={1}>{message}</Text>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StyleSheet, ScrollView, View } from 'react-native';
|
import { StyleSheet, View } from 'react-native';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import isEqual from 'lodash/isEqual';
|
import isEqual from 'lodash/isEqual';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
|
||||||
|
|
||||||
import { withTheme } from '../theme';
|
import { withTheme } from '../theme';
|
||||||
import { themedHeader } from '../utils/navigation';
|
import { themedHeader } from '../utils/navigation';
|
||||||
|
@ -224,7 +225,7 @@ class ModalBlockView extends React.Component {
|
||||||
const { blocks } = view;
|
const { blocks } = view;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView
|
<KeyboardAwareScrollView
|
||||||
style={[
|
style={[
|
||||||
styles.container,
|
styles.container,
|
||||||
{ backgroundColor: themes[theme].auxiliaryBackground }
|
{ backgroundColor: themes[theme].auxiliaryBackground }
|
||||||
|
@ -249,7 +250,7 @@ class ModalBlockView extends React.Component {
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
{loading ? <ActivityIndicator absolute size='large' theme={theme} /> : null}
|
{loading ? <ActivityIndicator absolute size='large' theme={theme} /> : null}
|
||||||
</ScrollView>
|
</KeyboardAwareScrollView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,6 +491,8 @@ class RoomsListView extends React.Component {
|
||||||
|
|
||||||
getRoomTitle = item => RocketChat.getRoomTitle(item)
|
getRoomTitle = item => RocketChat.getRoomTitle(item)
|
||||||
|
|
||||||
|
getRoomAvatar = item => RocketChat.getRoomAvatar(item)
|
||||||
|
|
||||||
goRoom = (item) => {
|
goRoom = (item) => {
|
||||||
this.cancelSearchingAndroid();
|
this.cancelSearchingAndroid();
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
|
@ -731,7 +733,7 @@ class RoomsListView extends React.Component {
|
||||||
userMentions={item.userMentions}
|
userMentions={item.userMentions}
|
||||||
isRead={this.getIsRead(item)}
|
isRead={this.getIsRead(item)}
|
||||||
favorite={item.f}
|
favorite={item.f}
|
||||||
avatar={item.name}
|
avatar={this.getRoomAvatar(item)}
|
||||||
lastMessage={item.lastMessage}
|
lastMessage={item.lastMessage}
|
||||||
name={this.getRoomTitle(item)}
|
name={this.getRoomTitle(item)}
|
||||||
_updatedAt={item.roomUpdatedAt}
|
_updatedAt={item.roomUpdatedAt}
|
||||||
|
|
Loading…
Reference in New Issue