diff --git a/app/actions/views/channel.js b/app/actions/views/channel.js index 77505f679..4c2cd15a1 100644 --- a/app/actions/views/channel.js +++ b/app/actions/views/channel.js @@ -10,11 +10,12 @@ import { fetchMyChannelsAndMembers, getChannelStats, selectChannel, - leaveChannel as serviceLeaveChannel + leaveChannel as serviceLeaveChannel, + unfavoriteChannel } from 'mattermost-redux/actions/channels'; import {getPosts, getPostsWithRetry, getPostsBefore, getPostsSinceWithRetry, getPostThread} from 'mattermost-redux/actions/posts'; import {getFilesForPost} from 'mattermost-redux/actions/files'; -import {savePreferences, deletePreferences} from 'mattermost-redux/actions/preferences'; +import {savePreferences} from 'mattermost-redux/actions/preferences'; import {getTeamMembersByIds} from 'mattermost-redux/actions/teams'; import {getProfilesInChannel} from 'mattermost-redux/actions/users'; import {General, Preferences} from 'mattermost-redux/constants'; @@ -276,7 +277,7 @@ export function closeDMChannel(channel) { const state = getState(); if (channel.isFavorite) { - unmarkFavorite(channel.id)(dispatch, getState); + unfavoriteChannel(channel.id)(dispatch, getState); } toggleDMChannel(channel.teammate_id, 'false')(dispatch, getState); @@ -291,7 +292,7 @@ export function closeGMChannel(channel) { const state = getState(); if (channel.isFavorite) { - unmarkFavorite(channel.id)(dispatch, getState); + unfavoriteChannel(channel.id)(dispatch, getState); } toggleGMChannel(channel.id, 'false')(dispatch, getState); @@ -301,33 +302,6 @@ export function closeGMChannel(channel) { }; } -export function markFavorite(channelId) { - return async (dispatch, getState) => { - const {currentUserId} = getState().entities.users; - const fav = [{ - user_id: currentUserId, - category: Preferences.CATEGORY_FAVORITE_CHANNEL, - name: channelId, - value: 'true' - }]; - - savePreferences(currentUserId, fav)(dispatch, getState); - }; -} - -export function unmarkFavorite(channelId) { - return async (dispatch, getState) => { - const {currentUserId} = getState().entities.users; - const fav = [{ - user_id: currentUserId, - category: Preferences.CATEGORY_FAVORITE_CHANNEL, - name: channelId - }]; - - deletePreferences(currentUserId, fav)(dispatch, getState); - }; -} - export function refreshChannelWithRetry(channelId) { return (dispatch, getState) => { getPostsWithRetry(channelId)(dispatch, getState); diff --git a/app/screens/channel_info/channel_info.js b/app/screens/channel_info/channel_info.js index ebedcd6ae..8ed5500f7 100644 --- a/app/screens/channel_info/channel_info.js +++ b/app/screens/channel_info/channel_info.js @@ -41,8 +41,8 @@ class ChannelInfo extends PureComponent { deleteChannel: PropTypes.func.isRequired, getChannelStats: PropTypes.func.isRequired, leaveChannel: PropTypes.func.isRequired, - markFavorite: PropTypes.func.isRequired, - unmarkFavorite: PropTypes.func.isRequired + favoriteChannel: PropTypes.func.isRequired, + unfavoriteChannel: PropTypes.func.isRequired }) }; @@ -194,8 +194,8 @@ class ChannelInfo extends PureComponent { handleFavorite = () => { const {isFavorite, actions, currentChannel} = this.props; - const {markFavorite, unmarkFavorite} = actions; - const toggleFavorite = isFavorite ? unmarkFavorite : markFavorite; + const {favoriteChannel, unfavoriteChannel} = actions; + const toggleFavorite = isFavorite ? unfavoriteChannel : favoriteChannel; this.setState({isFavorite: !isFavorite}); toggleFavorite(currentChannel.id); }; @@ -206,7 +206,7 @@ class ChannelInfo extends PureComponent { const isGroupMessage = channel.type === General.GM_CHANNEL; return !isDirectMessage && !isGroupMessage; - } + }; renderLeaveOrDeleteChannelRow = () => { const channel = this.props.currentChannel; @@ -215,7 +215,7 @@ class ChannelInfo extends PureComponent { const isGroupMessage = channel.type === General.GM_CHANNEL; return !isDefaultChannel && !isDirectMessage && !isGroupMessage; - } + }; renderCloseDirect = () => { const channel = this.props.currentChannel; @@ -223,7 +223,7 @@ class ChannelInfo extends PureComponent { const isGroupMessage = channel.type === General.GM_CHANNEL; return isDirectMessage || isGroupMessage; - } + }; render() { const { diff --git a/app/screens/channel_info/index.js b/app/screens/channel_info/index.js index 35d3e8bcc..5b42ae77c 100644 --- a/app/screens/channel_info/index.js +++ b/app/screens/channel_info/index.js @@ -7,13 +7,11 @@ import {connect} from 'react-redux'; import { closeDMChannel, closeGMChannel, - leaveChannel, - markFavorite, - unmarkFavorite + leaveChannel } from 'app/actions/views/channel'; import {getTheme} from 'app/selectors/preferences'; -import {getChannelStats, deleteChannel} from 'mattermost-redux/actions/channels'; +import {favoriteChannel, getChannelStats, deleteChannel, unfavoriteChannel} from 'mattermost-redux/actions/channels'; import {General} from 'mattermost-redux/constants'; import { getCurrentChannel, @@ -69,8 +67,8 @@ function mapDispatchToProps(dispatch) { deleteChannel, getChannelStats, leaveChannel, - markFavorite, - unmarkFavorite + favoriteChannel, + unfavoriteChannel }, dispatch) }; } diff --git a/yarn.lock b/yarn.lock index 3294c95de..2b0686dda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3878,7 +3878,7 @@ makeerror@1.0.x: mattermost-redux@mattermost/mattermost-redux#master: version "0.0.1" - resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/b09a04337301c1a3cbe8a5a7e726e305a9af4f41" + resolved "https://codeload.github.com/mattermost/mattermost-redux/tar.gz/c6115b3cfa934ed97a60a10727fa487df39a4043" dependencies: deep-equal "1.0.1" harmony-reflect "1.5.1" @@ -5249,7 +5249,7 @@ redux-devtools-instrument@^1.3.3: symbol-observable "^1.0.2" "redux-offline@git+https://github.com/enahum/redux-offline.git": - version "1.1.4" + version "1.1.5" resolved "git+https://github.com/enahum/redux-offline.git#4bd85e7e3b279a2b11fb4d587808d583d2b5e7b5" dependencies: redux-persist "^4.5.0"