Minor tweaks
This commit is contained in:
parent
a245af6c1c
commit
16fd57527a
|
@ -38,7 +38,6 @@ export const INQUIRY = createRequestTypes('INQUIRY', [...defaultTypes, 'SET_ENAB
|
||||||
export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT', 'INIT_LOCAL_SETTINGS', 'SET_MASTER_DETAIL']);
|
export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT', 'INIT_LOCAL_SETTINGS', 'SET_MASTER_DETAIL']);
|
||||||
export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']);
|
export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']);
|
||||||
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
|
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
|
||||||
export const CREATE_TEAM = createRequestTypes('CREATE_TEAM', [...defaultTypes]);
|
|
||||||
export const CREATE_DISCUSSION = createRequestTypes('CREATE_DISCUSSION', [...defaultTypes]);
|
export const CREATE_DISCUSSION = createRequestTypes('CREATE_DISCUSSION', [...defaultTypes]);
|
||||||
export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']);
|
export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']);
|
||||||
export const SERVER = createRequestTypes('SERVER', [
|
export const SERVER = createRequestTypes('SERVER', [
|
||||||
|
|
|
@ -715,5 +715,6 @@
|
||||||
"Private_Team": "Private Team",
|
"Private_Team": "Private Team",
|
||||||
"Read_Only_Team": "Read Only Team",
|
"Read_Only_Team": "Read Only Team",
|
||||||
"Broadcast_Team": "Broadcast Team",
|
"Broadcast_Team": "Broadcast Team",
|
||||||
"creating_team" : "creating team"
|
"creating_team" : "creating team",
|
||||||
|
"team-name-already-exists": "A team with that name already exists"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,20 @@
|
||||||
import log from '../../utils/log';
|
import log from '../../utils/log';
|
||||||
import updateMessages from './updateMessages';
|
import updateMessages from './updateMessages';
|
||||||
|
|
||||||
async function load({ rid: roomId, latest, t }) {
|
async function load({
|
||||||
let params = { roomId, count: 50 };
|
rid: roomId, latest, t, team
|
||||||
|
}) {
|
||||||
|
let params = { roomId: roomId || team.roomId, count: 50 };
|
||||||
|
let apiType;
|
||||||
if (latest) {
|
if (latest) {
|
||||||
params = { ...params, latest: new Date(latest).toISOString() };
|
params = { ...params, latest: new Date(latest).toISOString() };
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiType = this.roomTypeToApiType(t);
|
if (team.type) {
|
||||||
|
apiType = this.roomTypeToApiType('p');
|
||||||
|
} else {
|
||||||
|
apiType = this.roomTypeToApiType(t);
|
||||||
|
}
|
||||||
if (!apiType) {
|
if (!apiType) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ const handleRequest = function* handleRequest({ data }) {
|
||||||
const subCollection = db.get('subscriptions');
|
const subCollection = db.get('subscriptions');
|
||||||
yield db.action(async() => {
|
yield db.action(async() => {
|
||||||
await subCollection.create((s) => {
|
await subCollection.create((s) => {
|
||||||
s._raw = sanitizedRaw({ id: sub.rid }, subCollection.schema);
|
s._raw = sanitizedRaw({ id: sub.team ? sub.team.roomId : sub.rid }, subCollection.schema);
|
||||||
Object.assign(s, sub);
|
Object.assign(s, sub);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -94,16 +94,12 @@ const handleSuccess = function* handleSuccess({ data }) {
|
||||||
if (isMasterDetail) {
|
if (isMasterDetail) {
|
||||||
Navigation.navigate('DrawerNavigator');
|
Navigation.navigate('DrawerNavigator');
|
||||||
}
|
}
|
||||||
if (data.team) {
|
goRoom({ item: data.team ? data.team : data, isMasterDetail });
|
||||||
goRoom({ item: data.team, isMasterDetail });
|
|
||||||
} else {
|
|
||||||
goRoom({ item: data, isMasterDetail });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFailure = function handleFailure({ err }) {
|
const handleFailure = function handleFailure({ err }) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const msg = err.reason || I18n.t('There_was_an_error_while_action', { action: I18n.t('creating_channel') });
|
const msg = err.data ? I18n.t(err.data.error) : err.reason || I18n.t('There_was_an_error_while_action', { action: I18n.t('creating_channel') });
|
||||||
showErrorAlert(msg);
|
showErrorAlert(msg);
|
||||||
}, 300);
|
}, 300);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,19 +7,11 @@ const navigate = ({ item, isMasterDetail, ...props }) => {
|
||||||
if (isMasterDetail) {
|
if (isMasterDetail) {
|
||||||
navigationMethod = Navigation.replace;
|
navigationMethod = Navigation.replace;
|
||||||
}
|
}
|
||||||
console.log({ item });
|
|
||||||
if (item.roomId) {
|
|
||||||
navigationMethod('RoomView', {
|
navigationMethod('RoomView', {
|
||||||
rid: item.roomId || item.rid,
|
rid: item.roomId || item.rid,
|
||||||
name: RocketChat.getRoomTitle(item),
|
name: RocketChat.getRoomTitle(item),
|
||||||
roomUserId: RocketChat.getUidDirectMessage(item),
|
t: item.type ? 'p' : item.t,
|
||||||
...props
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
navigationMethod('RoomView', {
|
|
||||||
rid: item.rid,
|
|
||||||
name: RocketChat.getRoomTitle(item),
|
|
||||||
t: item.t,
|
|
||||||
prid: item.prid,
|
prid: item.prid,
|
||||||
room: item,
|
room: item,
|
||||||
search: item.search,
|
search: item.search,
|
||||||
|
@ -27,7 +19,6 @@ const navigate = ({ item, isMasterDetail, ...props }) => {
|
||||||
roomUserId: RocketChat.getUidDirectMessage(item),
|
roomUserId: RocketChat.getUidDirectMessage(item),
|
||||||
...props
|
...props
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const goRoom = async({ item = {}, isMasterDetail = false, ...props }) => {
|
export const goRoom = async({ item = {}, isMasterDetail = false, ...props }) => {
|
||||||
|
|
|
@ -50,7 +50,7 @@ class SelectedUsersView extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.init();
|
this.init();
|
||||||
|
this.flatlist = React.createRef();
|
||||||
const maxUsers = props.route.params?.maxUsers;
|
const maxUsers = props.route.params?.maxUsers;
|
||||||
this.state = {
|
this.state = {
|
||||||
maxUsers,
|
maxUsers,
|
||||||
|
@ -190,9 +190,13 @@ class SelectedUsersView extends React.Component {
|
||||||
if (users.length === 0) {
|
if (users.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const ITEM_WIDTH = 250;
|
||||||
return (
|
return (
|
||||||
<FlatList
|
<FlatList
|
||||||
data={users}
|
data={users}
|
||||||
|
ref={ref => this.flatlist = ref}
|
||||||
|
onContentSizeChange={() => this.flatlist.scrollToEnd()}
|
||||||
|
getItemLayout={(_, index) => ({ length: ITEM_WIDTH, offset: ITEM_WIDTH * index, index })}
|
||||||
keyExtractor={item => item._id}
|
keyExtractor={item => item._id}
|
||||||
style={[sharedStyles.separatorTop, { borderColor: themes[theme].separatorColor }]}
|
style={[sharedStyles.separatorTop, { borderColor: themes[theme].separatorColor }]}
|
||||||
contentContainerStyle={{ marginVertical: 5 }}
|
contentContainerStyle={{ marginVertical: 5 }}
|
||||||
|
|
Loading…
Reference in New Issue