PLT-5857 replace the service folder with mattermost-redux library (#348)
This commit is contained in:
parent
93687f31a0
commit
548633f5c0
172 changed files with 238 additions and 9646 deletions
|
|
@ -11,7 +11,7 @@ When filling in a section please remove the help text and the above text.
|
|||
#### Checklist
|
||||
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
|
||||
- [ ] Added or updated unit tests (required for all new features)
|
||||
- [ ] All new/modified APIs include changes to the drivers
|
||||
- [ ] All new/modified APIs include changes to [mattermost-redux](https://github.com/mattermost/mattermost-redux) (please link)
|
||||
- [ ] Has UI changes
|
||||
- [ ] Includes text changes and localization file updates
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
import {NavigationTypes} from 'app/constants';
|
||||
import Routes from 'app/navigation/routes';
|
||||
import {Constants} from 'service/constants';
|
||||
import {selectPost} from 'service/actions/posts';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
import {selectPost} from 'mattermost-redux/actions/posts';
|
||||
|
||||
export function goBack() {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
import {AsyncStorage} from 'react-native';
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import {logError, getLogErrorAction} from 'service/actions/errors';
|
||||
import {ChannelTypes, GeneralTypes, TeamsTypes, UsersTypes} from 'service/constants';
|
||||
import {logError, getLogErrorAction} from 'mattermost-redux/actions/errors';
|
||||
import {ChannelTypes, GeneralTypes, TeamsTypes, UsersTypes} from 'mattermost-redux/constants';
|
||||
|
||||
export function loadStorage() {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
@ -17,7 +18,6 @@ export function loadStorage() {
|
|||
const credentials = {token, url};
|
||||
|
||||
const currentChannelId = otherStorage[currentTeamId] ? otherStorage[currentTeamId].currentChannelId : '';
|
||||
|
||||
const actions = [];
|
||||
|
||||
if (credentials) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {updateUserNotifyProps} from 'service/actions/users';
|
||||
import {Preferences} from 'service/constants';
|
||||
import {savePreferences} from 'service/actions/preferences';
|
||||
import {updateUserNotifyProps} from 'mattermost-redux/actions/users';
|
||||
import {Preferences} from 'mattermost-redux/constants';
|
||||
import {savePreferences} from 'mattermost-redux/actions/preferences';
|
||||
|
||||
export function handleUpdateUserNotifyProps(notifyProps) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ import {
|
|||
getMyChannelMembers,
|
||||
selectChannel,
|
||||
leaveChannel as serviceLeaveChannel
|
||||
} from 'service/actions/channels';
|
||||
import {getPosts, getPostsSince} from 'service/actions/posts';
|
||||
import {getFilesForPost} from 'service/actions/files';
|
||||
import {savePreferences, deletePreferences} from 'service/actions/preferences';
|
||||
import {getTeamMembersByIds} from 'service/actions/teams';
|
||||
import {Constants, UsersTypes} from 'service/constants';
|
||||
import {getChannelByName, getDirectChannelName, isDirectChannelVisible} from 'service/utils/channel_utils';
|
||||
import {getPreferencesByCategory} from 'service/utils/preference_utils';
|
||||
} from 'mattermost-redux/actions/channels';
|
||||
import {getPosts, getPostsSince} from 'mattermost-redux/actions/posts';
|
||||
import {getFilesForPost} from 'mattermost-redux/actions/files';
|
||||
import {savePreferences, deletePreferences} from 'mattermost-redux/actions/preferences';
|
||||
import {getTeamMembersByIds} from 'mattermost-redux/actions/teams';
|
||||
import {Constants, UsersTypes} from 'mattermost-redux/constants';
|
||||
import {getChannelByName, getDirectChannelName, isDirectChannelVisible} from 'mattermost-redux/utils/channel_utils';
|
||||
import {getPreferencesByCategory} from 'mattermost-redux/utils/preference_utils';
|
||||
|
||||
export function loadChannelsIfNecessary(teamId) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
@ -45,7 +45,7 @@ export function loadChannelsIfNecessary(teamId) {
|
|||
export function loadProfilesAndTeamMembersForDMSidebar(teamId) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const currentUserId = state.entities.users.currentId;
|
||||
const {currentUserId} = state.entities.users;
|
||||
const {channels} = state.entities.channels;
|
||||
const {myPreferences} = state.entities.preferences;
|
||||
const {membersInTeam} = state.entities.teams;
|
||||
|
|
@ -92,7 +92,7 @@ export function loadPostsIfNecessary(channel) {
|
|||
const postsInChannel = state.entities.posts.postsByChannel[channel.id];
|
||||
|
||||
// Make sure we include a team id for DM channels
|
||||
const teamId = channel.team_id || state.entities.teams.currentId;
|
||||
const teamId = channel.team_id || state.entities.teams.currentTeamId;
|
||||
|
||||
// Get the first page of posts if it appears we haven't gotten it yet, like the webapp
|
||||
if (!postsInChannel || postsInChannel.length < Constants.POST_CHUNK_SIZE) {
|
||||
|
|
@ -111,8 +111,8 @@ export function loadFilesForPostIfNecessary(post) {
|
|||
const fileIdsForPost = files.fileIdsByPostId[post.id];
|
||||
|
||||
if (!fileIdsForPost) {
|
||||
const teamId = teams.currentId;
|
||||
await getFilesForPost(teamId, post.channel_id, post.id)(dispatch, getState);
|
||||
const {currentTeamId} = teams;
|
||||
await getFilesForPost(currentTeamId, post.channel_id, post.id)(dispatch, getState);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -120,9 +120,8 @@ export function loadFilesForPostIfNecessary(post) {
|
|||
export function selectInitialChannel(teamId) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const {channels, myMembers} = state.entities.channels;
|
||||
const currentChannelId = state.entities.channels.currentId;
|
||||
const currentUserId = state.entities.users.currentId;
|
||||
const {channels, currentChannelId, myMembers} = state.entities.channels;
|
||||
const {currentUserId} = state.entities.users;
|
||||
const currentChannel = channels[currentChannelId];
|
||||
const {myPreferences} = state.entities.preferences;
|
||||
|
||||
|
|
@ -148,7 +147,7 @@ export function selectInitialChannel(teamId) {
|
|||
|
||||
export function handleSelectChannel(channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
const currentTeamId = getState().entities.teams.currentId;
|
||||
const {currentTeamId} = getState().entities.teams;
|
||||
|
||||
await updateStorage(currentTeamId, {currentChannelId: channelId});
|
||||
await selectChannel(channelId)(dispatch, getState);
|
||||
|
|
@ -169,10 +168,10 @@ export function handlePostDraftChanged(channelId, postDraft) {
|
|||
export function toggleDMChannel(otherUserId, visible) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const userId = state.entities.users.currentId;
|
||||
const {currentUserId} = state.entities.users;
|
||||
|
||||
const dm = [{
|
||||
user_id: userId,
|
||||
user_id: currentUserId,
|
||||
category: Constants.CATEGORY_DIRECT_CHANNEL_SHOW,
|
||||
name: otherUserId,
|
||||
value: visible
|
||||
|
|
@ -192,7 +191,7 @@ export function closeDMChannel(channel) {
|
|||
|
||||
toggleDMChannel(channel.teammate_id, 'false')(dispatch, getState).then(() => {
|
||||
if (channel.isCurrent) {
|
||||
selectInitialChannel(state.entities.teams.currentId)(dispatch, getState);
|
||||
selectInitialChannel(state.entities.teams.currentTeamId)(dispatch, getState);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -200,9 +199,9 @@ export function closeDMChannel(channel) {
|
|||
|
||||
export function markFavorite(channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
const userId = getState().entities.users.currentId;
|
||||
const {currentUserId} = getState().entities.users;
|
||||
const fav = [{
|
||||
user_id: userId,
|
||||
user_id: currentUserId,
|
||||
category: Constants.CATEGORY_FAVORITE_CHANNEL,
|
||||
name: channelId,
|
||||
value: 'true'
|
||||
|
|
@ -213,9 +212,9 @@ export function markFavorite(channelId) {
|
|||
|
||||
export function unmarkFavorite(channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
const userId = getState().entities.users.currentId;
|
||||
const {currentUserId} = getState().entities.users;
|
||||
const fav = [{
|
||||
user_id: userId,
|
||||
user_id: currentUserId,
|
||||
category: Constants.CATEGORY_FAVORITE_CHANNEL,
|
||||
name: channelId
|
||||
}];
|
||||
|
|
@ -225,10 +224,10 @@ export function unmarkFavorite(channelId) {
|
|||
|
||||
export function leaveChannel(channel, reset = false) {
|
||||
return async (dispatch, getState) => {
|
||||
const {currentId: teamId} = getState().entities.teams;
|
||||
await serviceLeaveChannel(teamId, channel.id)(dispatch, getState);
|
||||
const {currentTeamId} = getState().entities.teams;
|
||||
await serviceLeaveChannel(currentTeamId, channel.id)(dispatch, getState);
|
||||
if (channel.isCurrent || reset) {
|
||||
await selectInitialChannel(teamId)(dispatch, getState);
|
||||
await selectInitialChannel(currentTeamId)(dispatch, getState);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {addChannelMember} from 'service/actions/channels';
|
||||
import {addChannelMember} from 'mattermost-redux/actions/channels';
|
||||
|
||||
export function handleAddChannelMembers(teamId, channelId, members) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {removeChannelMember} from 'service/actions/channels';
|
||||
import {removeChannelMember} from 'mattermost-redux/actions/channels';
|
||||
|
||||
export function handleRemoveChannelMembers(teamId, channelId, members) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import {handleSelectChannel} from './channel';
|
||||
import {createChannel} from 'service/actions/channels';
|
||||
import {getCurrentTeamId} from 'service/selectors/entities/teams';
|
||||
import {getCurrentUserId} from 'service/selectors/entities/users';
|
||||
import {cleanUpUrlable} from 'service/utils/channel_utils';
|
||||
import {createChannel} from 'mattermost-redux/actions/channels';
|
||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
import {cleanUpUrlable} from 'mattermost-redux/utils/channel_utils';
|
||||
|
||||
export function handleCreateChannel(displayName, purpose, header, type) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import {updateStorage} from 'app/actions/storage';
|
||||
import Client from 'service/client';
|
||||
import Client from 'mattermost-redux/client';
|
||||
|
||||
export function handleLoginIdChanged(loginId) {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {getDirectChannelName} from 'service/utils/channel_utils';
|
||||
import {createDirectChannel} from 'service/actions/channels';
|
||||
import {getTeamMember} from 'service/actions/teams';
|
||||
import {getDirectChannelName} from 'mattermost-redux/utils/channel_utils';
|
||||
import {createDirectChannel} from 'mattermost-redux/actions/channels';
|
||||
import {getTeamMember} from 'mattermost-redux/actions/teams';
|
||||
import {handleSelectChannel, toggleDMChannel} from 'app/actions/views/channel';
|
||||
|
||||
export function makeDirectChannel(otherUserId) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const {currentId} = state.entities.users;
|
||||
const channelName = getDirectChannelName(currentId, otherUserId);
|
||||
const {currentUserId} = state.entities.users;
|
||||
const channelName = getDirectChannelName(currentUserId, otherUserId);
|
||||
const {channels, myMembers} = state.entities.channels;
|
||||
const channel = Object.values(channels).find((c) => c.name === channelName);
|
||||
const teamId = state.entities.teams.currentId;
|
||||
const {currentTeamId} = state.entities.teams;
|
||||
|
||||
await getTeamMember(teamId, otherUserId)(dispatch, getState);
|
||||
await getTeamMember(currentTeamId, otherUserId)(dispatch, getState);
|
||||
|
||||
if (channel && myMembers[channel.id]) {
|
||||
await toggleDMChannel(otherUserId, 'true')(dispatch, getState);
|
||||
handleSelectChannel(channel.id)(dispatch, getState);
|
||||
} else {
|
||||
const created = await createDirectChannel(teamId, currentId, otherUserId)(dispatch, getState);
|
||||
const created = await createDirectChannel(currentTeamId, currentUserId, otherUserId)(dispatch, getState);
|
||||
if (created) {
|
||||
await toggleDMChannel(otherUserId, 'true')(dispatch, getState);
|
||||
handleSelectChannel(created.id)(dispatch, getState);
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ import {goToChannelView} from 'app/actions/views/load_team';
|
|||
import {handleTeamChange, selectFirstAvailableTeam} from 'app/actions/views/select_team';
|
||||
import {updateStorage} from 'app/actions/storage';
|
||||
|
||||
import Client from 'service/client';
|
||||
import {markChannelAsRead, viewChannel} from 'service/actions/channels';
|
||||
import {getClientConfig, getLicenseConfig, setServerVersion} from 'service/actions/general';
|
||||
import {loadMe} from 'service/actions/users';
|
||||
import {getClientConfig, getLicenseConfig, setServerVersion} from 'mattermost-redux/actions/general';
|
||||
import {markChannelAsRead, viewChannel} from 'mattermost-redux/actions/channels';
|
||||
|
||||
export function goToSelectServer() {
|
||||
return async (dispatch, getState) => {
|
||||
|
|
@ -27,15 +25,6 @@ export function goToSelectServer() {
|
|||
};
|
||||
}
|
||||
|
||||
export function setStoreFromLocalData(data) {
|
||||
return async (dispatch, getState) => {
|
||||
Client.setToken(data.token);
|
||||
Client.setUrl(data.url);
|
||||
|
||||
return loadMe()(dispatch, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function loadConfigAndLicense(serverVersion) {
|
||||
return async (dispatch, getState) => {
|
||||
getClientConfig()(dispatch, getState);
|
||||
|
|
@ -67,7 +56,7 @@ export function goToNotification(notification) {
|
|||
loadChannelsIfNecessary(teamId)(dispatch, getState);
|
||||
} else {
|
||||
await selectFirstAvailableTeam()(dispatch, getState);
|
||||
teamId = getState().entities.teams.currentId;
|
||||
teamId = getState().entities.teams.currentTeamId;
|
||||
}
|
||||
|
||||
const channelId = data.channel_id;
|
||||
|
|
@ -82,7 +71,6 @@ export function goToNotification(notification) {
|
|||
export default {
|
||||
goToSelectServer,
|
||||
loadConfigAndLicense,
|
||||
setStoreFromLocalData,
|
||||
queueNotification,
|
||||
clearNotification,
|
||||
goToNotification
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
import {ChannelTypes, TeamsTypes} from 'service/constants';
|
||||
import {ChannelTypes, TeamsTypes} from 'mattermost-redux/constants';
|
||||
import {updateStorage} from 'app/actions/storage';
|
||||
|
||||
export function handleTeamChange(team) {
|
||||
return async (dispatch, getState) => {
|
||||
const currentTeamId = getState().entities.teams.currentId;
|
||||
const {currentTeamId} = getState().entities.teams;
|
||||
if (currentTeamId === team.id) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,11 @@ import {
|
|||
TouchableOpacity,
|
||||
View
|
||||
} from 'react-native';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
import Loading from 'app/components/loading';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import EventEmitter from 'service/utils/event_emitter';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {changeOpacity} from 'app/utils/theme';
|
||||
|
||||
class ActionButton extends PureComponent {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import FormattedText from 'app/components/formatted_text';
|
|||
import ProfilePicture from 'app/components/profile_picture';
|
||||
import {makeStyleSheetFromTheme, changeOpacity} from 'app/utils/theme';
|
||||
|
||||
import {RequestStatus} from 'service/constants';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
|
||||
const AT_MENTION_REGEX = /\B(@([^@\r\n\s]*))$/i;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {autocompleteUsersInChannel} from 'service/actions/users';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getDefaultChannel} from 'service/selectors/entities/channels';
|
||||
import {getAutocompleteUsersInCurrentChannel} from 'service/selectors/entities/users';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {autocompleteUsersInChannel} from 'mattermost-redux/actions/users';
|
||||
import {getDefaultChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getAutocompleteUsersInCurrentChannel} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import AtMention from './at_mention';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const currentChannelId = state.entities.channels.currentId;
|
||||
const {currentChannelId} = state.entities.channels;
|
||||
|
||||
let postDraft;
|
||||
if (ownProps.rootId.length) {
|
||||
|
|
@ -23,9 +23,9 @@ function mapStateToProps(state, ownProps) {
|
|||
|
||||
return {
|
||||
...ownProps,
|
||||
currentUserId: state.entities.users.currentId,
|
||||
currentUserId: state.entities.users.currentUserId,
|
||||
currentChannelId,
|
||||
currentTeamId: state.entities.teams.currentId,
|
||||
currentTeamId: state.entities.teams.currentTeamId,
|
||||
defaultChannel: getDefaultChannel(state),
|
||||
postDraft,
|
||||
autocompleteUsersInCurrentChannel: getAutocompleteUsersInCurrentChannel(state),
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
import FormattedText from 'app/components/formatted_text';
|
||||
import {makeStyleSheetFromTheme, changeOpacity} from 'app/utils/theme';
|
||||
|
||||
import {RequestStatus} from 'service/constants';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
|
||||
const CHANNEL_MENTION_REGEX = /\B(~([^~\r\n]*))$/i;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {autocompleteChannels} from 'service/actions/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getAutocompleteChannelWithSections} from 'service/selectors/entities/channels';
|
||||
import {autocompleteChannels} from 'mattermost-redux/actions/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getAutocompleteChannelWithSections} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
||||
import ChannelMention from './channel_mention';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const currentChannelId = state.entities.channels.currentId;
|
||||
const {currentChannelId} = state.entities.channels;
|
||||
|
||||
let postDraft;
|
||||
if (ownProps.rootId.length) {
|
||||
|
|
@ -23,7 +23,7 @@ function mapStateToProps(state, ownProps) {
|
|||
return {
|
||||
...ownProps,
|
||||
currentChannelId,
|
||||
currentTeamId: state.entities.teams.currentId,
|
||||
currentTeamId: state.entities.teams.currentTeamId,
|
||||
postDraft,
|
||||
autocompleteChannels: getAutocompleteChannelWithSections(state),
|
||||
requestStatus: state.requests.channels.autocompleteChannels.status,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import Icon from 'react-native-vector-icons/FontAwesome';
|
|||
import {OnlineStatus, AwayStatus, OfflineStatus} from 'app/components/status_icons';
|
||||
import {changeOpacity} from 'app/utils/theme';
|
||||
|
||||
import {Constants} from 'service/constants';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
|
||||
import Badge from 'app/components/badge';
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {
|
|||
View
|
||||
} from 'react-native';
|
||||
import {injectIntl, intlShape} from 'react-intl';
|
||||
import {Constants} from 'service/constants';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
import LineDivider from 'app/components/line_divider';
|
||||
import ChannelDrawerItem from './channel_drawer_item';
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {getDisplayableErrors} from 'service/selectors/errors';
|
||||
import {dismissError, clearErrors} from 'service/actions/errors';
|
||||
import {getDisplayableErrors} from 'mattermost-redux/selectors/errors';
|
||||
import {dismissError, clearErrors} from 'mattermost-redux/actions/errors';
|
||||
|
||||
import ErrorList from './error_list';
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import {
|
|||
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import * as Utils from 'service/utils/file_utils.js';
|
||||
import * as Utils from 'mattermost-redux/utils/file_utils.js';
|
||||
|
||||
import FileAttachmentIcon from './file_attachment_icon';
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {
|
|||
StyleSheet
|
||||
} from 'react-native';
|
||||
|
||||
import * as Utils from 'service/utils/file_utils';
|
||||
import * as Utils from 'mattermost-redux/utils/file_utils';
|
||||
|
||||
import audioIcon from 'assets/images/icons/audio.png';
|
||||
import codeIcon from 'assets/images/icons/code.png';
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {makeGetFilesForPost} from 'service/selectors/entities/files';
|
||||
import {makeGetFilesForPost} from 'mattermost-redux/selectors/entities/files';
|
||||
import {loadFilesForPostIfNecessary} from 'app/actions/views/channel';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import FileAttachmentList from './file_attachment_list';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {logout} from 'service/actions/users';
|
||||
import {logout} from 'mattermost-redux/actions/users';
|
||||
|
||||
import Logout from './logout.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import ProfilePicture from 'app/components/profile_picture';
|
|||
import FileAttachmentList from 'app/components/file_attachment_list/file_attachment_list_container';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import {isSystemMessage} from 'service/utils/post_utils.js';
|
||||
import {isSystemMessage} from 'mattermost-redux/utils/post_utils.js';
|
||||
|
||||
export default class Post extends Component {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@
|
|||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
|
||||
import {getMyPreferences, getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {goToUserProfile} from 'app/actions/navigation';
|
||||
import {getUser} from 'service/selectors/entities/users';
|
||||
import {displayUsername} from 'service/utils/user_utils';
|
||||
import {getUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
import Post from './post';
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import DateHeader from './date_header';
|
|||
import LoadMorePosts from './load_more_posts';
|
||||
import NewMessagesDivider from './new_messages_divider';
|
||||
|
||||
import {Constants} from 'service/constants';
|
||||
import {addDatesToPostList} from 'service/utils/post_utils';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
import {addDatesToPostList} from 'mattermost-redux/utils/post_utils';
|
||||
|
||||
const style = StyleSheet.create({
|
||||
container: {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import PostList from './post_list';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {createPost} from 'service/actions/posts';
|
||||
import {userTyping} from 'service/actions/websocket';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentUserId} from 'service/selectors/entities/users';
|
||||
import {getUsersTyping} from 'service/selectors/entities/typing';
|
||||
import {createPost} from 'mattermost-redux/actions/posts';
|
||||
import {userTyping} from 'mattermost-redux/actions/websocket';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getUsersTyping} from 'mattermost-redux/selectors/entities/typing';
|
||||
|
||||
import PostTextbox from './post_textbox';
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
|||
|
||||
import placeholder from 'assets/images/profile.jpg';
|
||||
|
||||
import Client from 'service/client';
|
||||
import Client from 'mattermost-redux/client';
|
||||
|
||||
const statusToIcon = {
|
||||
online: 'check',
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getStatusesByIdsBatchedDebounced} from 'service/actions/users';
|
||||
import {getStatusForUserId} from 'service/selectors/entities/users';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getStatusesByIdsBatchedDebounced} from 'mattermost-redux/actions/users';
|
||||
import {getStatusForUserId} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import ProfilePicture from './profile_picture';
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ import {bindActionCreators} from 'redux';
|
|||
import {connect} from 'react-redux';
|
||||
|
||||
import {goToNotification, queueNotification} from 'app/actions/views/root';
|
||||
import {setDeviceToken} from 'service/actions/general';
|
||||
import {getUnreads} from 'service/selectors/entities/channels';
|
||||
import {setDeviceToken} from 'mattermost-redux/actions/general';
|
||||
import {getUnreads} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
||||
import PushNotification from './push_notification';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const {currentId: currentTeamId} = state.entities.teams;
|
||||
const {currentId: currentChannelId} = state.entities.channels;
|
||||
const {currentTeamId} = state.entities.teams;
|
||||
const {currentChannelId} = state.entities.channels;
|
||||
|
||||
return {
|
||||
...ownProps,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {changeOpacity} from 'app/utils/theme';
|
|||
import icon from 'assets/images/icon.png';
|
||||
import {GooglePlaySenderId} from 'assets/config.json';
|
||||
|
||||
import {Constants} from 'service/constants';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
|
||||
export default class PushNotification extends PureComponent {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ import DeviceInfo from 'react-native-device-info';
|
|||
|
||||
import PushNotification from 'app/components/push_notification';
|
||||
|
||||
import Client from 'service/client';
|
||||
import {Constants} from 'service/constants';
|
||||
import {getTranslations} from 'service/i18n';
|
||||
import EventEmitter from 'service/utils/event_emitter';
|
||||
import Client from 'mattermost-redux/client';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
import {getTranslations} from 'app/i18n';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
export default class Root extends PureComponent {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ import Config from 'assets/config.json';
|
|||
|
||||
import {flushToStorage} from 'app/actions/storage';
|
||||
import {goToNotification, loadConfigAndLicense, queueNotification} from 'app/actions/views/root';
|
||||
import {setAppState, setDeviceToken} from 'service/actions/general';
|
||||
import {setAppState, setDeviceToken} from 'mattermost-redux/actions/general';
|
||||
|
||||
import Root from './root';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
const users = state.entities.users;
|
||||
const currentUserId = users.currentId;
|
||||
const {currentId: currentTeamId} = state.entities.teams;
|
||||
const {currentId: currentChannelId} = state.entities.channels;
|
||||
const {currentUserId} = users;
|
||||
const {currentTeamId} = state.entities.teams;
|
||||
const {currentChannelId} = state.entities.channels;
|
||||
|
||||
let locale = Config.DefaultLocale;
|
||||
if (currentUserId && users.profiles[currentUserId]) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import keyMirror from 'service/utils/key_mirror';
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
|
||||
const NavigationTypes = keyMirror({
|
||||
NAVIGATION_PUSH: null,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import keyMirror from 'service/utils/key_mirror';
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
|
||||
const StorageTypes = keyMirror({
|
||||
SAVE_TO_STORAGE: null,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import keyMirror from 'service/utils/key_mirror';
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
|
||||
const ViewTypes = keyMirror({
|
||||
SERVER_URL_CHANGED: null,
|
||||
|
|
|
|||
|
|
@ -11,11 +11,12 @@ const state = {
|
|||
appState: false,
|
||||
credentials: {},
|
||||
config: {},
|
||||
deviceToken: '',
|
||||
license: {},
|
||||
deviceToken: ''
|
||||
serverVersion: ''
|
||||
},
|
||||
users: {
|
||||
currentId: '',
|
||||
currentUserId: '',
|
||||
mySessions: [],
|
||||
myAudits: [],
|
||||
profiles: {},
|
||||
|
|
@ -26,7 +27,7 @@ const state = {
|
|||
search: {}
|
||||
},
|
||||
teams: {
|
||||
currentId: '',
|
||||
currentTeamId: '',
|
||||
teams: {},
|
||||
myMembers: {},
|
||||
membersInTeam: {},
|
||||
|
|
@ -34,7 +35,7 @@ const state = {
|
|||
openTeamIds: new Set()
|
||||
},
|
||||
channels: {
|
||||
currentId: '',
|
||||
currentChannelId: '',
|
||||
channels: {},
|
||||
myMembers: {},
|
||||
stats: {}
|
||||
|
|
@ -50,6 +51,7 @@ const state = {
|
|||
},
|
||||
typing: {}
|
||||
},
|
||||
errors: [],
|
||||
requests: {
|
||||
channels: {
|
||||
getChannel: {
|
||||
|
|
|
|||
|
|
@ -15,8 +15,9 @@ import {closeDrawers, goBack} from 'app/actions/navigation';
|
|||
import Drawer from 'app/components/drawer';
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
import {RouteTransitions} from 'app/navigation/routes';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import ErrorList from 'app/components/error_list';
|
||||
|
||||
import NavigationModal from './navigation_modal';
|
||||
|
||||
const navigationPanResponder = NavigationExperimental.Card.CardStackPanResponder;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import {
|
|||
UserProfile
|
||||
} from 'app/scenes';
|
||||
|
||||
import keyMirror from 'service/utils/key_mirror';
|
||||
import keyMirror from 'mattermost-redux/utils/key_mirror';
|
||||
|
||||
export const RouteTransitions = keyMirror({
|
||||
Horizontal: null
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import {NavigationExperimental} from 'react-native';
|
||||
|
||||
import {UsersTypes} from 'service/constants';
|
||||
import {UsersTypes} from 'mattermost-redux/constants';
|
||||
import {NavigationTypes} from 'app/constants';
|
||||
|
||||
import Routes from 'app/navigation/routes';
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {combineReducers} from 'redux';
|
|||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
|
||||
import {ChannelTypes} from 'service/constants';
|
||||
import {ChannelTypes} from 'mattermost-redux/constants';
|
||||
|
||||
function drafts(state = {}, action) {
|
||||
switch (action.type) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {combineReducers} from 'redux';
|
|||
|
||||
import Config from 'assets/config.json';
|
||||
|
||||
import {UsersTypes} from 'service/constants';
|
||||
import {UsersTypes} from 'mattermost-redux/constants';
|
||||
|
||||
function locale(state = Config.DefaultLocale, action) {
|
||||
switch (action.type) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import {combineReducers} from 'redux';
|
||||
import {UsersTypes} from 'service/constants';
|
||||
import {UsersTypes} from 'mattermost-redux/constants';
|
||||
import {ViewTypes} from 'app/constants';
|
||||
|
||||
function loginId(state = '', action) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import {combineReducers} from 'redux';
|
||||
|
||||
import {UsersTypes} from 'service/constants';
|
||||
import {UsersTypes} from 'mattermost-redux/constants';
|
||||
import {ViewTypes} from 'app/constants';
|
||||
|
||||
function title(state = '', action) {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import {
|
|||
|
||||
import TextInputWithLocalizedPlaceholder from 'app/components/text_input_with_localized_placeholder';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import EventEmitter from 'service/utils/event_emitter';
|
||||
import {Preferences, RequestStatus} from 'service/constants';
|
||||
import {getPreferencesByCategory} from 'service/utils/preference_utils';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
import {Preferences, RequestStatus} from 'mattermost-redux/constants';
|
||||
import {getPreferencesByCategory} from 'mattermost-redux/utils/preference_utils';
|
||||
|
||||
import Section from './section';
|
||||
import SectionItem from './section_item';
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import {bindActionCreators} from 'redux';
|
|||
|
||||
import {goBack} from 'app/actions/navigation';
|
||||
import {handleUpdateUserNotifyProps} from 'app/actions/views/account_notifications';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentUser} from 'service/selectors/entities/users';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import {
|
|||
import FormattedText from 'app/components/formatted_text';
|
||||
import Loading from 'app/components/loading';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import EventEmitter from 'service/utils/event_emitter';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
class AccountNotifcationsButton extends PureComponent {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
|
||||
import {goToAccountNotifications} from 'app/actions/navigation';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
import AccountSettings from './account_settings';
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import KeyboardLayout from 'app/components/layout/keyboard_layout';
|
|||
import Loading from 'app/components/loading';
|
||||
import PostTextbox from 'app/components/post_textbox';
|
||||
|
||||
import {Constants} from 'service/constants';
|
||||
import EventEmitter from 'service/utils/event_emitter';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
import ChannelDrawerButton from './channel_drawer_button';
|
||||
import ChannelMenuButton from './channel_menu_button';
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@ import {
|
|||
selectInitialChannel,
|
||||
handlePostDraftChanged
|
||||
} from 'app/actions/views/channel';
|
||||
import {startPeriodicStatusUpdates, stopPeriodicStatusUpdates} from 'service/actions/users';
|
||||
import {startPeriodicStatusUpdates, stopPeriodicStatusUpdates} from 'mattermost-redux/actions/users';
|
||||
import {selectFirstAvailableTeam} from 'app/actions/views/select_team';
|
||||
|
||||
import {getCurrentChannel} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentTeam} from 'service/selectors/entities/teams';
|
||||
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import {
|
||||
init as initWebSocket,
|
||||
close as closeWebSocket
|
||||
} from 'service/actions/websocket';
|
||||
} from 'mattermost-redux/actions/websocket';
|
||||
|
||||
import Channel from './channel';
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import {
|
|||
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||
import Badge from 'app/components/badge';
|
||||
|
||||
import {getUnreads} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getUnreads} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
function ChannelDrawerButton(props) {
|
||||
let badge;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
} from 'react-native';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
function ChannelMenuButton(props) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import React, {PropTypes, PureComponent} from 'react';
|
||||
|
||||
import {Constants, RequestStatus} from 'service/constants';
|
||||
import {Constants, RequestStatus} from 'mattermost-redux/constants';
|
||||
|
||||
import Loading from 'app/components/loading';
|
||||
import PostList from 'app/components/post_list';
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ import {createSelector} from 'reselect';
|
|||
|
||||
import {goToThread} from 'app/actions/navigation';
|
||||
import {loadPostsIfNecessary} from 'app/actions/views/channel';
|
||||
import {getPostsBefore} from 'service/actions/posts';
|
||||
import {getPostsBefore} from 'mattermost-redux/actions/posts';
|
||||
|
||||
import {getAllPosts, getPostsInCurrentChannel} from 'service/selectors/entities/posts';
|
||||
import {getCurrentChannelMembership} from 'service/selectors/entities/channels';
|
||||
import {getAllPosts, getPostsInCurrentChannel} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getCurrentChannelMembership} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
||||
import ChannelPostList from './channel_post_list';
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import {
|
|||
} from 'react-native';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||
|
||||
import {getCurrentChannel} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
function ChannelTitle(props) {
|
||||
const channelName = props.currentChannel.display_name;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
function AddMemberButton(props) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
|
||||
import {handleAddChannelMembers} from 'app/actions/views/channel_add_members';
|
||||
import {goBack} from 'app/actions/navigation';
|
||||
import {getCurrentChannel, getCurrentChannelStats} from 'service/selectors/entities/channels';
|
||||
import {getMyPreferences, getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentTeam, getCurrentTeamStats} from 'service/selectors/entities/teams';
|
||||
import {getProfilesNotInCurrentChannel} from 'service/selectors/entities/users';
|
||||
import {getTeamStats} from 'service/actions/teams';
|
||||
import {getProfilesNotInChannel} from 'service/actions/users';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getCurrentChannel, getCurrentChannelStats} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentTeam, getCurrentTeamStats} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getProfilesNotInCurrentChannel} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getTeamStats} from 'mattermost-redux/actions/teams';
|
||||
import {getProfilesNotInChannel} from 'mattermost-redux/actions/users';
|
||||
|
||||
import ChannelAddMembers from './channel_add_members';
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import {connect} from 'react-redux';
|
|||
import {closeDrawers} from 'app/actions/navigation';
|
||||
import {handleSelectChannel} from 'app/actions/views/channel';
|
||||
|
||||
import {getChannelsByCategory, getCurrentChannel} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentTeam} from 'service/selectors/entities/teams';
|
||||
import {getChannelsByCategory, getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import {viewChannel, markChannelAsRead} from 'service/actions/channels';
|
||||
import {viewChannel, markChannelAsRead} from 'mattermost-redux/actions/channels';
|
||||
|
||||
import ChannelDrawer from './channel_drawer.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from 'react-native';
|
||||
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import {Constants} from 'service/constants';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
|
||||
import ChannelInfoHeader from './channel_info_header';
|
||||
import ChannelInfoRow from './channel_info_row';
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import {bindActionCreators} from 'redux';
|
|||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
|
||||
import {goToChannelMembers, goToChannelAddMembers, goBack} from 'app/actions/navigation';
|
||||
import {getChannelStats, deleteChannel} from 'service/actions/channels';
|
||||
import {getChannelStats, deleteChannel} from 'mattermost-redux/actions/channels';
|
||||
import {markFavorite, unmarkFavorite, leaveChannel} from 'app/actions/views/channel';
|
||||
import {getCurrentChannel, getCurrentChannelStats, getChannelsByCategory, canManageChannelMembers} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getUser} from 'service/selectors/entities/users';
|
||||
import {getCurrentChannel, getCurrentChannelStats, getChannelsByCategory, canManageChannelMembers} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getUser} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import ChannelInfo from './channel_info';
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ function mapStateToProps(state, ownProps) {
|
|||
|
||||
return {
|
||||
...ownProps,
|
||||
currentTeamId: state.entities.teams.currentId,
|
||||
currentTeamId: state.entities.teams.currentTeamId,
|
||||
currentChannel,
|
||||
currentChannelCreatorName,
|
||||
currentChannelMemberCount,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import {injectIntl, intlShape} from 'react-intl';
|
|||
import MemberList from 'app/components/custom_list';
|
||||
import {createMembersSections, loadingText} from 'app/utils/member_list';
|
||||
import MemberListRow from 'app/components/custom_list/member_list_row';
|
||||
import {displayUsername} from 'service/utils/user_utils';
|
||||
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
||||
import {makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import ChannelMembersTitle from './channel_members_title';
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
|
||||
import {goBack} from 'app/actions/navigation';
|
||||
import {handleRemoveChannelMembers} from 'app/actions/views/channel_members';
|
||||
import {getCurrentChannel, getCurrentChannelStats, canManageChannelMembers} from 'service/selectors/entities/channels';
|
||||
import {getMyPreferences, getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentTeam} from 'service/selectors/entities/teams';
|
||||
import {getProfilesInCurrentChannel} from 'service/selectors/entities/users';
|
||||
import {getProfilesInChannel} from 'service/actions/users';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getCurrentChannel, getCurrentChannelStats, canManageChannelMembers} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
import {getProfilesInCurrentChannel} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getProfilesInChannel} from 'mattermost-redux/actions/users';
|
||||
|
||||
import ChannelMembers from './channel_members';
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ function mapStateToProps(state) {
|
|||
currentChannel: getCurrentChannel(state),
|
||||
currentChannelMembers: getProfilesInCurrentChannel(state),
|
||||
currentChannelMemberCount,
|
||||
currentUserId: state.entities.users.currentId,
|
||||
currentUserId: state.entities.users.currentUserId,
|
||||
currentTeam: getCurrentTeam(state),
|
||||
preferences: getMyPreferences(state),
|
||||
requestStatus: state.requests.users.getProfilesInChannel.status,
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import React, {PropTypes} from 'react';
|
|||
import {connect} from 'react-redux';
|
||||
import {View} from 'react-native';
|
||||
|
||||
import {getCurrentChannel, canManageChannelMembers} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentChannel, canManageChannelMembers} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import {
|
|||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
|
||||
import {getCurrentChannel, canManageChannelMembers} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentChannel, canManageChannelMembers} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
function RemoveMemberButton(props) {
|
||||
const {canManageUsers} = props;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import TextInputWithLocalizedPlaceholder from 'app/components/text_input_with_lo
|
|||
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
|
||||
import {Constants, RequestStatus} from 'service/constants';
|
||||
import EventEmitter from 'service/utils/event_emitter';
|
||||
import {Constants, RequestStatus} from 'mattermost-redux/constants';
|
||||
import EventEmitter from 'mattermost-redux/utils/event_emitter';
|
||||
|
||||
import ActionButton from 'app/components/action_button';
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
import {goBack, closeModal} from 'app/actions/navigation';
|
||||
import {handleCreateChannel} from 'app/actions/views/create_channel';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import CreateChannel from './create_channel';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import {PropTypes, PureComponent} from 'react';
|
||||
|
||||
import {RequestStatus} from 'service/constants';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
|
||||
export default class LoadTeam extends PureComponent {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {connect} from 'react-redux';
|
|||
import {goToChannelView} from 'app/actions/views/load_team';
|
||||
import {clearNotification, goToNotification} from 'app/actions/views/root';
|
||||
import {handleTeamChange} from 'app/actions/views/select_team';
|
||||
import {getCurrentTeam} from 'service/selectors/entities/teams';
|
||||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import LoadTeam from './load_team.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import {GlobalStyles} from 'app/styles';
|
|||
|
||||
import logo from 'assets/images/logo.png';
|
||||
|
||||
import {RequestStatus} from 'service/constants';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
|
||||
class Login extends Component {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
|
||||
import LoginActions from 'app/actions/views/login';
|
||||
import {goToMfa, goToLoadTeam} from 'app/actions/navigation';
|
||||
import {checkMfa, login} from 'service/actions/users';
|
||||
import {checkMfa, login} from 'mattermost-redux/actions/users';
|
||||
|
||||
import Login from './login.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import {GlobalStyles} from 'app/styles';
|
|||
|
||||
import logo from 'assets/images/logo.png';
|
||||
|
||||
import RequestStatus from 'service/constants/request_status';
|
||||
import RequestStatus from 'mattermost-redux/constants/request_status';
|
||||
|
||||
export default class Mfa extends Component {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {bindActionCreators} from 'redux';
|
|||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
|
||||
import {goBack} from 'app/actions/navigation';
|
||||
import {login} from 'service/actions/users';
|
||||
import {login} from 'mattermost-redux/actions/users';
|
||||
|
||||
import Mfa from './mfa';
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
function CreateButton(props) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ import {bindActionCreators} from 'redux';
|
|||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
|
||||
import {goBack, goToCreateChannel} from 'app/actions/navigation';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getMoreChannels as getMoreChannelsSelector} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getMoreChannels as getMoreChannelsSelector} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {handleSelectChannel} from 'app/actions/views/channel';
|
||||
import {getMoreChannels, joinChannel, searchMoreChannels} from 'service/actions/channels';
|
||||
import {getMoreChannels, joinChannel, searchMoreChannels} from 'mattermost-redux/actions/channels';
|
||||
|
||||
import MoreChannels from './more_channels';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
const {currentId: currentUserId} = state.entities.users;
|
||||
const {currentId: currentTeamId} = state.entities.teams;
|
||||
const {currentUserId} = state.entities.users;
|
||||
const {currentTeamId} = state.entities.teams;
|
||||
const {getMoreChannels: requestStatus} = state.requests.channels;
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import FormattedText from 'app/components/formatted_text';
|
|||
import Loading from 'app/components/loading';
|
||||
import SearchBar from 'app/components/search_bar';
|
||||
|
||||
import {Constants, RequestStatus} from 'service/constants';
|
||||
import {Constants, RequestStatus} from 'mattermost-redux/constants';
|
||||
import {makeStyleSheetFromTheme, changeOpacity} from 'app/utils/theme';
|
||||
|
||||
import CreateButton from './create_button';
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
|
||||
import {goBack} from 'app/actions/navigation';
|
||||
import {makeDirectChannel} from 'app/actions/views/more_dms';
|
||||
import {getProfiles, searchProfiles} from 'service/actions/users';
|
||||
import {getMyPreferences, getTheme} from 'service/selectors/entities/preferences';
|
||||
import {searchProfiles as searchSelector} from 'service/selectors/entities/users';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getProfiles, searchProfiles} from 'mattermost-redux/actions/users';
|
||||
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {searchProfiles as searchSelector} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
import MoreDirectMessages from './more_dms';
|
||||
|
||||
|
|
@ -17,9 +18,9 @@ function mapStateToProps(state, ownProps) {
|
|||
const {getProfiles: requestStatus, searchProfiles: searchRequest} = state.requests.users;
|
||||
|
||||
function getUsers() {
|
||||
const {profiles, currentId} = state.entities.users;
|
||||
const {profiles, currentUserId} = state.entities.users;
|
||||
const users = {...profiles};
|
||||
Reflect.deleteProperty(users, currentId);
|
||||
Reflect.deleteProperty(users, currentUserId);
|
||||
return Object.values(users).sort((a, b) => {
|
||||
const nameA = a.username;
|
||||
const nameB = b.username;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import Loading from 'app/components/loading';
|
|||
import MemberList from 'app/components/custom_list';
|
||||
import SearchBar from 'app/components/search_bar';
|
||||
import {createMembersSections, loadingText, renderMemberRow} from 'app/utils/member_list';
|
||||
import {Constants, RequestStatus} from 'service/constants';
|
||||
import {Constants, RequestStatus} from 'mattermost-redux/constants';
|
||||
import {makeStyleSheetFromTheme, changeOpacity} from 'app/utils/theme';
|
||||
|
||||
class MoreDirectMessages extends PureComponent {
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import {bindActionCreators} from 'redux';
|
|||
import {connect} from 'react-redux';
|
||||
|
||||
import {goToModalAccountSettings, goBack, goToModalSelectTeam} from 'app/actions/navigation';
|
||||
import {clearErrors} from 'service/actions/errors';
|
||||
import {clearErrors} from 'mattermost-redux/actions/errors';
|
||||
|
||||
import {logout} from 'service/actions/users';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {logout} from 'mattermost-redux/actions/users';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import RightMenuDrawer from './right_menu_drawer';
|
||||
|
||||
|
|
@ -17,8 +17,8 @@ function mapStateToProps(state, ownProps) {
|
|||
...ownProps,
|
||||
theme: getTheme(state),
|
||||
errors: state.errors,
|
||||
currentUserId: state.entities.users.currentId,
|
||||
currentTeamId: state.entities.teams.currentId
|
||||
currentUserId: state.entities.users.currentUserId,
|
||||
currentTeamId: state.entities.teams.currentTeamId
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import React, {PropTypes, PureComponent} from 'react';
|
|||
import {AsyncStorage} from 'react-native';
|
||||
import Loading from 'app/components/loading';
|
||||
|
||||
import {RequestStatus} from 'service/constants';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
|
||||
export default class Root extends PureComponent {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,12 @@ import {bindActionCreators} from 'redux';
|
|||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
|
||||
import {loadStorage, removeStorage} from 'app/actions/storage';
|
||||
import {goToSelectServer, setStoreFromLocalData} from 'app/actions/views/root';
|
||||
import {goToSelectServer} from 'app/actions/views/root';
|
||||
import {handleServerUrlChanged} from 'app/actions/views/select_server';
|
||||
import {goToLoadTeam} from 'app/actions/navigation';
|
||||
|
||||
import {setStoreFromLocalData} from 'mattermost-redux/actions/general';
|
||||
|
||||
import Root from './root';
|
||||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
|
||||
import {handleSuccessfulLogin} from 'app/actions/views/login';
|
||||
import {goToLoadTeam} from 'app/actions/navigation';
|
||||
import {setStoreFromLocalData} from 'app/actions/views/root';
|
||||
import {setStoreFromLocalData} from 'mattermost-redux/actions/general';
|
||||
|
||||
import Saml from './saml';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ import {isValidUrl, stripTrailingSlashes} from 'app/utils/url';
|
|||
|
||||
import logo from 'assets/images/logo.png';
|
||||
|
||||
import {RequestStatus} from 'service/constants';
|
||||
import Client from 'service/client';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
import Client from 'mattermost-redux/client';
|
||||
|
||||
export default class SelectServer extends PureComponent {
|
||||
static propTypes = {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import {bindActionCreators} from 'redux';
|
|||
|
||||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
|
||||
import {getPing, resetPing} from 'service/actions/general';
|
||||
import {RequestStatus} from 'service/constants';
|
||||
import {getPing, resetPing} from 'mattermost-redux/actions/general';
|
||||
import {RequestStatus} from 'mattermost-redux/constants';
|
||||
import * as SelectServerActions from 'app/actions/views/select_server';
|
||||
|
||||
import SelectServer from './select_server';
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
import {goBack} from 'app/actions/navigation';
|
||||
import {handleTeamChange} from 'app/actions/views/select_team';
|
||||
|
||||
import {getCurrentTeam} from 'service/selectors/entities/teams';
|
||||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import SelectTeam from './select_team.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
|
||||
import {handleCommentDraftChanged} from 'app/actions/views/thread';
|
||||
import {selectPost} from 'service/actions/posts';
|
||||
import {selectPost} from 'mattermost-redux/actions/posts';
|
||||
|
||||
import {makeGetPostsForThread} from 'service/selectors/entities/posts';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getCurrentTeamId} from 'service/selectors/entities/teams';
|
||||
import {makeGetPostsForThread} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import navigationSceneConnect from '../navigationSceneConnect';
|
||||
import Thread from './thread';
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import {
|
|||
View
|
||||
} from 'react-native';
|
||||
|
||||
import {Constants} from 'service/constants';
|
||||
import {getCurrentChannel} from 'service/selectors/entities/channels';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {Constants} from 'mattermost-redux/constants';
|
||||
import {getCurrentChannel} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import FormattedText from 'app/components/formatted_text';
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
|
||||
import ProfilePicture from 'app/components/profile_picture';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import {getFullName} from 'service/utils/user_utils';
|
||||
import {getFullName} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
import UserProfileRow from './user_profile_row';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import {bindActionCreators} from 'redux';
|
||||
|
||||
import {handleSendMessage} from 'app/actions/views/user_profile';
|
||||
import {getTheme} from 'service/selectors/entities/preferences';
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
import UserProfile from './user_profile';
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ import navigationSceneConnect from '../navigationSceneConnect';
|
|||
|
||||
function mapStateToProps(state, ownProps) {
|
||||
return {
|
||||
currentUserId: state.entities.users.currentId,
|
||||
currentUserId: state.entities.users.currentUserId,
|
||||
user: state.entities.users.profiles[ownProps.userId],
|
||||
theme: getTheme(state)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,14 +6,11 @@ import {createSelector} from 'reselect';
|
|||
import Config from 'assets/config.json';
|
||||
import Themes from 'assets/themes.json';
|
||||
|
||||
import {Preferences} from 'service/constants';
|
||||
import {getPreferenceKey} from 'service/utils/preference_utils';
|
||||
import {Preferences} from 'mattermost-redux/constants';
|
||||
import {getPreferenceKey} from 'mattermost-redux/utils/preference_utils';
|
||||
|
||||
import {getCurrentTeamId} from './teams';
|
||||
|
||||
export function getMyPreferences(state) {
|
||||
return state.entities.preferences.myPreferences;
|
||||
}
|
||||
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
export const getTheme = createSelector(
|
||||
getMyPreferences,
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import appReducer from 'app/reducers';
|
||||
import configureServiceStore from 'service/store';
|
||||
import configureServiceStore from 'mattermost-redux/store';
|
||||
|
||||
function getAppReducer() {
|
||||
return require('../../app/reducers'); // eslint-disable-line global-require
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import React from 'react';
|
||||
import MemberListRow from 'app/components/custom_list/member_list_row';
|
||||
import {displayUsername} from 'service/utils/user_utils';
|
||||
import {displayUsername} from 'mattermost-redux/utils/user_utils';
|
||||
|
||||
export const loadingText = {
|
||||
id: 'mobile.loading_members',
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"harmony-reflect": "1.5.1",
|
||||
"intl": "1.2.5",
|
||||
"isomorphic-fetch": "2.2.1",
|
||||
"mattermost-redux": "mattermost/mattermost-redux#release-3.7",
|
||||
"react": "15.4.1",
|
||||
"react-addons-pure-render-mixin": "15.4.1",
|
||||
"react-intl": "2.2.2",
|
||||
|
|
@ -29,6 +30,7 @@
|
|||
"reselect": "2.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "6.23.0",
|
||||
"babel-eslint": "7.1.1",
|
||||
"babel-plugin-module-resolver": "2.4.0",
|
||||
"babel-preset-es2015": "6.18.0",
|
||||
|
|
@ -51,8 +53,7 @@
|
|||
"react-test-renderer": "15.4.1",
|
||||
"redux-logger": "2.7.4",
|
||||
"remote-redux-devtools": "0.5.7",
|
||||
"remote-redux-devtools-on-debugger": "0.7.0",
|
||||
"ws": "1.1.1"
|
||||
"remote-redux-devtools-on-debugger": "0.7.0"
|
||||
},
|
||||
"scripts": {
|
||||
"check": "node_modules/.bin/eslint --ext \".js\" --ignore-pattern node_modules --quiet .",
|
||||
|
|
|
|||
|
|
@ -1,753 +0,0 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {
|
||||
Constants,
|
||||
ChannelTypes,
|
||||
Preferences,
|
||||
PreferencesTypes,
|
||||
UsersTypes
|
||||
} from 'service/constants';
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
import Client from 'service/client';
|
||||
|
||||
import {logError, getLogErrorAction} from './errors';
|
||||
import {forceLogoutIfNecessary} from './helpers';
|
||||
|
||||
export function selectChannel(channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
try {
|
||||
dispatch({
|
||||
type: ChannelTypes.SELECT_CHANNEL,
|
||||
data: channelId
|
||||
}, getState);
|
||||
} catch (error) {
|
||||
logError(error)(dispatch);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function createChannel(channel, userId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.CREATE_CHANNEL_REQUEST
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_MEMBERS_REQUEST
|
||||
}
|
||||
]), getState);
|
||||
|
||||
let created;
|
||||
try {
|
||||
created = await Client.createChannel(channel);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.CREATE_CHANNEL_FAILURE,
|
||||
error
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_MEMBERS_FAILURE,
|
||||
error
|
||||
},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return null;
|
||||
}
|
||||
|
||||
const member = {
|
||||
channel_id: created.id,
|
||||
user_id: userId,
|
||||
roles: `${Constants.CHANNEL_USER_ROLE} ${Constants.CHANNEL_ADMIN_ROLE}`,
|
||||
last_viewed_at: 0,
|
||||
msg_count: 0,
|
||||
mention_count: 0,
|
||||
notify_props: {desktop: 'default', mark_unread: 'all'},
|
||||
last_update_at: created.create_at
|
||||
};
|
||||
|
||||
const actions = [];
|
||||
const {channels, myMembers} = getState().entities.channels;
|
||||
|
||||
if (!channels[created.id]) {
|
||||
actions.push({type: ChannelTypes.RECEIVED_CHANNEL, data: created});
|
||||
}
|
||||
|
||||
if (!myMembers[created.id]) {
|
||||
actions.push({type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBER, data: member});
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
...actions,
|
||||
{
|
||||
type: ChannelTypes.CREATE_CHANNEL_SUCCESS
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_MEMBERS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
|
||||
return created;
|
||||
};
|
||||
}
|
||||
|
||||
export function createDirectChannel(teamId, userId, otherUserId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.CREATE_CHANNEL_REQUEST}, getState);
|
||||
|
||||
let created;
|
||||
try {
|
||||
created = await Client.createDirectChannel(teamId, otherUserId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.CREATE_CHANNEL_FAILURE, error},
|
||||
{type: ChannelTypes.CHANNEL_MEMBERS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return null;
|
||||
}
|
||||
|
||||
const member = {
|
||||
channel_id: created.id,
|
||||
user_id: userId,
|
||||
roles: `${Constants.CHANNEL_USER_ROLE} ${Constants.CHANNEL_ADMIN_ROLE}`,
|
||||
last_viewed_at: 0,
|
||||
msg_count: 0,
|
||||
mention_count: 0,
|
||||
notify_props: {desktop: 'default', mark_unread: 'all'},
|
||||
last_update_at: created.create_at
|
||||
};
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNEL,
|
||||
data: created
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBER,
|
||||
data: member
|
||||
},
|
||||
{
|
||||
type: PreferencesTypes.RECEIVED_PREFERENCES,
|
||||
data: [{category: Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, name: otherUserId, value: 'true'}]
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CREATE_CHANNEL_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
|
||||
return created;
|
||||
};
|
||||
}
|
||||
|
||||
export function updateChannel(channel) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.UPDATE_CHANNEL_REQUEST}, getState);
|
||||
|
||||
let updated;
|
||||
try {
|
||||
updated = await Client.updateChannel(channel);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.UPDATE_CHANNEL_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNEL,
|
||||
data: updated
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.UPDATE_CHANNEL_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function updateChannelNotifyProps(userId, teamId, channelId, props) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.NOTIFY_PROPS_REQUEST}, getState);
|
||||
|
||||
const data = {
|
||||
user_id: userId,
|
||||
channel_id: channelId,
|
||||
...props
|
||||
};
|
||||
|
||||
let notifyProps;
|
||||
try {
|
||||
notifyProps = await Client.updateChannelNotifyProps(teamId, data);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.NOTIFY_PROPS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNEL_PROPS,
|
||||
data: {
|
||||
channel_id: channelId,
|
||||
notifyProps
|
||||
}
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.NOTIFY_PROPS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function getChannel(teamId, channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.CHANNEL_REQUEST}, getState);
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await Client.getChannel(teamId, channelId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.CHANNELS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNEL,
|
||||
data: data.channel
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_SUCCESS
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBER,
|
||||
data: data.member
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function fetchMyChannelsAndMembers(teamId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.CHANNELS_REQUEST
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_MEMBERS_REQUEST
|
||||
}
|
||||
]), getState);
|
||||
|
||||
let channels;
|
||||
let channelMembers;
|
||||
try {
|
||||
const channelsRequest = Client.getChannels(teamId);
|
||||
const channelMembersRequest = Client.getMyChannelMembers(teamId);
|
||||
|
||||
channels = await channelsRequest;
|
||||
channelMembers = await channelMembersRequest;
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.CHANNELS_FAILURE, error},
|
||||
{type: ChannelTypes.CHANNEL_MEMBERS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNELS,
|
||||
data: channels
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNELS_SUCCESS
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBERS,
|
||||
data: channelMembers
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_MEMBERS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function getMyChannelMembers(teamId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.CHANNEL_MEMBERS_REQUEST}, getState);
|
||||
|
||||
let channelMembers;
|
||||
try {
|
||||
const channelMembersRequest = Client.getMyChannelMembers(teamId);
|
||||
|
||||
channelMembers = await channelMembersRequest;
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.CHANNEL_MEMBERS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBERS,
|
||||
data: channelMembers
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_MEMBERS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function leaveChannel(teamId, channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.LEAVE_CHANNEL_REQUEST}, getState);
|
||||
|
||||
try {
|
||||
await Client.leaveChannel(teamId, channelId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.LEAVE_CHANNEL_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.LEAVE_CHANNEL,
|
||||
data: channelId
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.LEAVE_CHANNEL_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function joinChannel(userId, teamId, channelId, channelName) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.JOIN_CHANNEL_REQUEST}, getState);
|
||||
|
||||
let channel;
|
||||
try {
|
||||
if (channelId) {
|
||||
channel = await Client.joinChannel(teamId, channelId);
|
||||
} else if (channelName) {
|
||||
channel = await Client.joinChannelByName(teamId, channelName);
|
||||
}
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.JOIN_CHANNEL_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
const channelMember = {
|
||||
channel_id: channel.id,
|
||||
user_id: userId,
|
||||
roles: `${Constants.CHANNEL_USER_ROLE}`,
|
||||
last_viewed_at: 0,
|
||||
msg_count: 0,
|
||||
mention_count: 0,
|
||||
notify_props: {desktop: 'default', mark_unread: 'all'},
|
||||
last_update_at: new Date().getTime()
|
||||
};
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNEL,
|
||||
data: channel
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBER,
|
||||
data: channelMember
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.JOIN_CHANNEL_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function deleteChannel(teamId, channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.DELETE_CHANNEL_REQUEST}, getState);
|
||||
|
||||
try {
|
||||
await Client.deleteChannel(teamId, channelId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.DELETE_CHANNEL_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
const entities = getState().entities;
|
||||
const {channels, currentId} = entities.channels;
|
||||
if (channelId === currentId) {
|
||||
const channel = Object.keys(channels).filter((key) => channels[key].name === Constants.DEFAULT_CHANNEL);
|
||||
let defaultChannelId = '';
|
||||
if (channel.length) {
|
||||
defaultChannelId = channel[0];
|
||||
}
|
||||
|
||||
dispatch({type: ChannelTypes.SELECT_CHANNEL, data: defaultChannelId}, getState);
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNEL_DELETED,
|
||||
data: channelId
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.DELETE_CHANNEL_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function viewChannel(teamId, channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const {currentId} = state.entities.channels;
|
||||
let prevChannelId = '';
|
||||
|
||||
if (channelId !== currentId) {
|
||||
prevChannelId = currentId;
|
||||
}
|
||||
|
||||
dispatch({type: ChannelTypes.UPDATE_LAST_VIEWED_REQUEST}, getState);
|
||||
|
||||
try {
|
||||
// this API should return the timestamp that was set
|
||||
await Client.viewChannel(teamId, channelId, prevChannelId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.UPDATE_LAST_VIEWED_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch({type: ChannelTypes.UPDATE_LAST_VIEWED_SUCCESS}, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function getMoreChannels(teamId, offset, limit = Constants.CHANNELS_CHUNK_SIZE) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.MORE_CHANNELS_REQUEST}, getState);
|
||||
|
||||
let channels;
|
||||
try {
|
||||
channels = await Client.getMoreChannels(teamId, offset, limit);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.MORE_CHANNELS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return null;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_MORE_CHANNELS,
|
||||
data: await channels
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.MORE_CHANNELS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
|
||||
return channels;
|
||||
};
|
||||
}
|
||||
|
||||
export function searchMoreChannels(teamId, term) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.MORE_CHANNELS_REQUEST}, getState);
|
||||
|
||||
let channels;
|
||||
try {
|
||||
channels = await Client.searchMoreChannels(teamId, term);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.MORE_CHANNELS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_MORE_CHANNELS,
|
||||
data: await channels
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.MORE_CHANNELS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function getChannelStats(teamId, channelId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.CHANNEL_STATS_REQUEST}, getState);
|
||||
|
||||
let stat;
|
||||
try {
|
||||
stat = await Client.getChannelStats(teamId, channelId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.CHANNEL_STATS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_CHANNEL_STATS,
|
||||
data: stat
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.CHANNEL_STATS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function addChannelMember(teamId, channelId, userId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.ADD_CHANNEL_MEMBER_REQUEST}, getState);
|
||||
|
||||
try {
|
||||
await Client.addChannelMember(teamId, channelId, userId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.ADD_CHANNEL_MEMBER_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: UsersTypes.RECEIVED_PROFILE_IN_CHANNEL,
|
||||
data: {user_id: userId},
|
||||
id: channelId
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.ADD_CHANNEL_MEMBER_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function removeChannelMember(teamId, channelId, userId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.REMOVE_CHANNEL_MEMBER_REQUEST}, getState);
|
||||
|
||||
try {
|
||||
await Client.removeChannelMember(teamId, channelId, userId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.REMOVE_CHANNEL_MEMBER_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: UsersTypes.RECEIVED_PROFILE_NOT_IN_CHANNEL,
|
||||
data: {user_id: userId},
|
||||
id: channelId
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.REMOVE_CHANNEL_MEMBER_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function updateChannelHeader(channelId, header) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ChannelTypes.UPDATE_CHANNEL_HEADER,
|
||||
data: {
|
||||
channelId,
|
||||
header
|
||||
}
|
||||
}, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function updateChannelPurpose(channelId, purpose) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: ChannelTypes.UPDATE_CHANNEL_PURPOSE,
|
||||
data: {
|
||||
channelId,
|
||||
purpose
|
||||
}
|
||||
}, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function markChannelAsRead(channelId, prevChannelId) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
const {channels} = state.entities.channels;
|
||||
let totalMsgCount = 0;
|
||||
if (channels[channelId]) {
|
||||
totalMsgCount = channels[channelId].total_msg_count;
|
||||
}
|
||||
const actions = [{
|
||||
type: ChannelTypes.RECEIVED_LAST_VIEWED,
|
||||
data: {
|
||||
channel_id: channelId,
|
||||
last_viewed_at: new Date().getTime(),
|
||||
total_msg_count: totalMsgCount
|
||||
}
|
||||
}];
|
||||
|
||||
if (prevChannelId) {
|
||||
let prevTotalMsgCount = 0;
|
||||
if (channels[prevChannelId]) {
|
||||
prevTotalMsgCount = channels[prevChannelId].total_msg_count;
|
||||
}
|
||||
actions.push({
|
||||
type: ChannelTypes.RECEIVED_LAST_VIEWED,
|
||||
data: {
|
||||
channel_id: prevChannelId,
|
||||
last_viewed_at: new Date().getTime(),
|
||||
total_msg_count: prevTotalMsgCount
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dispatch(batchActions([...actions]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function markChannelAsUnread(channelId, mentionsArray) {
|
||||
return async (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const {channels, myMembers} = state.entities.channels;
|
||||
const currentUserId = state.entities.users.currentId;
|
||||
const channel = {...channels[channelId]};
|
||||
const member = {...myMembers[channelId]};
|
||||
|
||||
if (channel && member) {
|
||||
channel.total_msg_count++;
|
||||
if (member.notify_props && member.notify_props.mark_unread === Constants.MENTION) {
|
||||
member.msg_count++;
|
||||
}
|
||||
|
||||
let mentions = [];
|
||||
if (mentionsArray) {
|
||||
mentions = JSON.parse(mentionsArray);
|
||||
if (mentions.indexOf(currentUserId) !== -1) {
|
||||
member.mention_count++;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(batchActions([{
|
||||
type: ChannelTypes.RECEIVED_MY_CHANNEL_MEMBER,
|
||||
data: member
|
||||
}, {
|
||||
type: ChannelTypes.RECEIVED_CHANNEL,
|
||||
data: channel
|
||||
}]), getState);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function autocompleteChannels(teamId, term) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: ChannelTypes.AUTOCOMPLETE_CHANNELS_REQUEST}, getState);
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await Client.autocompleteChannels(teamId, term);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: ChannelTypes.AUTOCOMPLETE_CHANNELS_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: ChannelTypes.RECEIVED_AUTOCOMPLETE_CHANNELS,
|
||||
data,
|
||||
teamId
|
||||
},
|
||||
{
|
||||
type: ChannelTypes.AUTOCOMPLETE_CHANNELS_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
selectChannel,
|
||||
createChannel,
|
||||
createDirectChannel,
|
||||
updateChannel,
|
||||
updateChannelNotifyProps,
|
||||
getChannel,
|
||||
fetchMyChannelsAndMembers,
|
||||
getMyChannelMembers,
|
||||
leaveChannel,
|
||||
joinChannel,
|
||||
deleteChannel,
|
||||
viewChannel,
|
||||
getMoreChannels,
|
||||
searchMoreChannels,
|
||||
getChannelStats,
|
||||
addChannelMember,
|
||||
removeChannelMember,
|
||||
updateChannelHeader,
|
||||
updateChannelPurpose,
|
||||
markChannelAsRead,
|
||||
markChannelAsUnread,
|
||||
autocompleteChannels
|
||||
};
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {ErrorTypes} from 'service/constants';
|
||||
|
||||
export function dismissErrorObject(index) {
|
||||
return {
|
||||
type: ErrorTypes.DISMISS_ERROR,
|
||||
index
|
||||
};
|
||||
}
|
||||
|
||||
export function dismissError(index) {
|
||||
return async (dispatch) => {
|
||||
dispatch(dismissErrorObject(index));
|
||||
};
|
||||
}
|
||||
|
||||
export function getLogErrorAction(error, displayable = true) {
|
||||
return {
|
||||
type: ErrorTypes.LOG_ERROR,
|
||||
displayable,
|
||||
error
|
||||
};
|
||||
}
|
||||
|
||||
export function logError(error, displayable = true) {
|
||||
return async (dispatch) => {
|
||||
// do something with the incoming error
|
||||
// like sending it to analytics
|
||||
|
||||
dispatch(getLogErrorAction(error, displayable));
|
||||
};
|
||||
}
|
||||
|
||||
export function clearErrors() {
|
||||
return async (dispatch) => {
|
||||
dispatch({type: ErrorTypes.CLEAR_ERRORS});
|
||||
};
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
import Client from 'service/client';
|
||||
import {FilesTypes} from 'service/constants';
|
||||
import {getLogErrorAction} from 'service/actions/errors';
|
||||
import {forceLogoutIfNecessary} from './helpers';
|
||||
|
||||
export function getFilesForPost(teamId, channelId, postId) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: FilesTypes.FETCH_FILES_FOR_POST_REQUEST}, getState);
|
||||
let files;
|
||||
|
||||
try {
|
||||
files = await Client.getFileInfosForPost(teamId, channelId, postId);
|
||||
} catch (error) {
|
||||
forceLogoutIfNecessary(error, dispatch);
|
||||
dispatch(batchActions([
|
||||
{type: FilesTypes.FETCH_FILES_FOR_POST_FAILURE, error},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(batchActions([
|
||||
{
|
||||
type: FilesTypes.RECEIVED_FILES_FOR_POST,
|
||||
data: files,
|
||||
postId
|
||||
},
|
||||
{
|
||||
type: FilesTypes.FETCH_FILES_FOR_POST_SUCCESS
|
||||
}
|
||||
]), getState);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
|
||||
import Client from 'service/client';
|
||||
import {bindClientFunc, FormattedError} from './helpers.js';
|
||||
import {GeneralTypes} from 'service/constants';
|
||||
import {getMyChannelMembers} from './channels';
|
||||
import {getLogErrorAction} from 'service/actions/errors';
|
||||
|
||||
export function getPing() {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: GeneralTypes.PING_REQUEST}, getState);
|
||||
|
||||
let data;
|
||||
const pingError = new FormattedError(
|
||||
'mobile.server_ping_failed',
|
||||
'Cannot connect to the server. Please check your server URL and internet connection.'
|
||||
);
|
||||
try {
|
||||
data = await Client.getPing();
|
||||
if (!data.version) {
|
||||
// successful ping but not the right return data
|
||||
dispatch(batchActions([
|
||||
{type: GeneralTypes.PING_FAILURE, error: pingError},
|
||||
getLogErrorAction(pingError)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
dispatch(batchActions([
|
||||
{type: GeneralTypes.PING_FAILURE, error: pingError},
|
||||
getLogErrorAction(error)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch({type: GeneralTypes.PING_SUCCESS, data}, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function resetPing() {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: GeneralTypes.PING_RESET}, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function getClientConfig() {
|
||||
return bindClientFunc(
|
||||
Client.getClientConfig,
|
||||
GeneralTypes.CLIENT_CONFIG_REQUEST,
|
||||
[GeneralTypes.CLIENT_CONFIG_RECEIVED, GeneralTypes.CLIENT_CONFIG_SUCCESS],
|
||||
GeneralTypes.CLIENT_CONFIG_FAILURE
|
||||
);
|
||||
}
|
||||
|
||||
export function getLicenseConfig() {
|
||||
return bindClientFunc(
|
||||
Client.getLicenseConfig,
|
||||
GeneralTypes.CLIENT_LICENSE_REQUEST,
|
||||
[GeneralTypes.CLIENT_LICENSE_RECEIVED, GeneralTypes.CLIENT_LICENSE_SUCCESS],
|
||||
GeneralTypes.CLIENT_LICENSE_FAILURE
|
||||
);
|
||||
}
|
||||
|
||||
export function logClientError(message, level = 'ERROR') {
|
||||
return bindClientFunc(
|
||||
Client.logClientError,
|
||||
GeneralTypes.LOG_CLIENT_ERROR_REQUEST,
|
||||
GeneralTypes.LOG_CLIENT_ERROR_SUCCESS,
|
||||
GeneralTypes.LOG_CLIENT_ERROR_FAILURE,
|
||||
message,
|
||||
level
|
||||
);
|
||||
}
|
||||
|
||||
export function setAppState(state) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: GeneralTypes.RECEIVED_APP_STATE, data: state}, getState);
|
||||
|
||||
if (state) {
|
||||
const teamId = getState().entities.teams.currentId;
|
||||
if (teamId) {
|
||||
getMyChannelMembers(teamId)(dispatch, getState);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function setServerVersion(serverVersion) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: GeneralTypes.RECEIVED_SERVER_VERSION, data: serverVersion}, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export function setDeviceToken(token) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({type: GeneralTypes.RECEIVED_APP_DEVICE_TOKEN, data: token}, getState);
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
getPing,
|
||||
getClientConfig,
|
||||
getLicenseConfig,
|
||||
logClientError,
|
||||
setAppState,
|
||||
setServerVersion,
|
||||
setDeviceToken
|
||||
};
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import {batchActions} from 'redux-batched-actions';
|
||||
import Client from 'service/client';
|
||||
import {UsersTypes} from 'service/constants';
|
||||
import {getLogErrorAction} from './errors';
|
||||
const HTTP_UNAUTHORIZED = 401;
|
||||
|
||||
export async function forceLogoutIfNecessary(err, dispatch) {
|
||||
if (err.status_code === HTTP_UNAUTHORIZED && err.url.indexOf('/login') === -1) {
|
||||
dispatch({type: UsersTypes.LOGOUT_REQUEST});
|
||||
await Client.logout();
|
||||
dispatch({type: UsersTypes.LOGOUT_SUCCESS});
|
||||
}
|
||||
}
|
||||
|
||||
function dispatcher(type, data, dispatch, getState) {
|
||||
if (type.indexOf('SUCCESS') === -1) { // we don't want to pass the data for the request types
|
||||
dispatch(requestSuccess(type, data), getState);
|
||||
} else {
|
||||
dispatch(requestData(type), getState);
|
||||
}
|
||||
}
|
||||
|
||||
export function requestData(type) {
|
||||
return {
|
||||
type
|
||||
};
|
||||
}
|
||||
|
||||
export function requestSuccess(type, data) {
|
||||
return {
|
||||
type,
|
||||
data
|
||||
};
|
||||
}
|
||||
|
||||
export function requestFailure(type, error) {
|
||||
return {
|
||||
type,
|
||||
error
|
||||
};
|
||||
}
|
||||
|
||||
export function bindClientFunc(clientFunc, request, success, failure, ...args) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch(requestData(request), getState);
|
||||
|
||||
let data = null;
|
||||
try {
|
||||
data = await clientFunc(...args);
|
||||
} catch (err) {
|
||||
forceLogoutIfNecessary(err, dispatch);
|
||||
dispatch(batchActions([
|
||||
requestFailure(failure, err),
|
||||
getLogErrorAction(err)
|
||||
]), getState);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(success)) {
|
||||
success.forEach((s) => {
|
||||
dispatcher(s, data, dispatch, getState);
|
||||
});
|
||||
} else {
|
||||
dispatcher(success, data, dispatch, getState);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Debounce function based on underscores modified to use es6 and a cb
|
||||
export function debounce(func, wait, immediate, cb) {
|
||||
let timeout;
|
||||
return function fx(...args) {
|
||||
const runLater = () => {
|
||||
timeout = null;
|
||||
if (!immediate) {
|
||||
Reflect.apply(func, this, args);
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
};
|
||||
const callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(runLater, wait);
|
||||
if (callNow) {
|
||||
Reflect.apply(func, this, args);
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export class FormattedError extends Error {
|
||||
constructor(id, defaultMessage, values = {}) {
|
||||
super(defaultMessage);
|
||||
this.intl = {
|
||||
id,
|
||||
defaultMessage,
|
||||
values
|
||||
};
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue