Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleChannelViewedEvent(msg) {
// Useful for when multiple devices have the app open to different channels
if ((!window.isActive || getCurrentChannelId(getState()) !== msg.data.channel_id) &&
getCurrentUserId(getState()) === msg.broadcast.user_id) {
dispatch(markChannelAsRead(msg.data.channel_id, '', false));
}
}
function handleChannelViewedEvent(msg) {
// Useful for when multiple devices have the app open to different channels
if ((!window.isActive || getCurrentChannelId(getState()) !== msg.data.channel_id) &&
getCurrentUserId(getState()) === msg.broadcast.user_id) {
dispatch(markChannelAsRead(msg.data.channel_id, '', false));
}
}
function defaultRoute(state) {
const userId = getCurrentUserId(state);
if (!userId) {
return '/login';
}
const teamId = LocalStorageStore.getPreviousTeamId(userId);
const locale = getCurrentLocale(state);
let team = getTeam(state, teamId);
const myMember = getMyTeamMember(state, teamId);
if (!team || !myMember || !myMember.team_id) {
team = null;
let myTeams = getMyTeams(state);
if (myTeams.length > 0) {
function mapStateToProps(state, ownProps) {
const channelId = ownProps.channelId;
const myMember = getMyChannelMember(state, channelId);
return {
channelId,
currentUserId: getCurrentUserId(state),
postIds: getPostIdsInChannel(state, channelId),
lastViewedAt: myMember && myMember.last_viewed_at,
theme: getTheme(state),
};
}
const config = getConfig(state);
const {createChannel: createChannelRequest} = state.requests.channels;
const militaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
const enableTimezone = isTimezoneEnabled(state);
return {
config,
createChannelRequest,
currentDisplayName: state.views.channel.displayName,
user: state.entities.users.profiles[ownProps.userId],
bot: getBotAccounts(state)[ownProps.userId],
teammateNameDisplay: getTeammateNameDisplaySetting(state),
enableTimezone,
militaryTime,
theme: getTheme(state),
isMyUser: getCurrentUserId(state) === ownProps.userId,
isLandscape: isLandscape(state),
};
}
function mapStateToProps(state) {
const config = getConfig(state);
const siteName = config.SiteName;
return {
isLoggedIn: Boolean(getCurrentUserId(state)),
siteName,
user: getCurrentUser(state),
};
}
function mapStateToProps(state, ownProps) {
const config = getConfig(state);
return {
currentUserId: getCurrentUserId(state),
enableLinkPreviews: config.EnableLinkPreviews === 'true',
openGraphData: getOpenGraphMetadataForUrl(state, ownProps.postId, ownProps.link),
previewEnabled: getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.LINK_PREVIEW_DISPLAY, true),
};
}
return function mapStateToProps(state, ownProps) {
const post = getPost(state, ownProps.postId);
const channelId = post ? post.channel_id : '';
const channel = getChannel(state, channelId) || {};
const teamId = channel.team_id;
const channelIsArchived = channel.delete_at !== 0;
const channelIsReadOnly = isChannelReadOnlyById(state, channelId);
const currentUserId = getCurrentUserId(state);
const reactions = getReactionsForPostSelector(state, ownProps.postId);
let canAddReaction = true;
let canRemoveReaction = true;
let canAddMoreReactions = true;
if (channelIsArchived || channelIsReadOnly) {
canAddReaction = false;
canRemoveReaction = false;
canAddMoreReactions = false;
} else if (hasNewPermissions(state)) {
canAddReaction = haveIChannelPermission(state, {
team: teamId,
channel: channelId,
permission: Permissions.ADD_REACTION,
});
canAddMoreReactions = Object.values(reactions).length < MAX_ALLOWED_REACTIONS;
function mapStateToProps(state, ownProps) {
return {
...ownProps,
channelIsLoading: state.views.channel.loading,
currentUserId: getCurrentUserId(state),
typing: getUsersTyping(state),
theme: getTheme(state),
uploadFileRequestStatus: state.requests.files.uploadFiles.status
};
}
export async function loadProfilesForDM() {
const state = getState();
const channels = getMyChannels(state);
const newPreferences = [];
const profilesToLoad = [];
const profileIds = [];
const currentUserId = Selectors.getCurrentUserId(state);
for (let i = 0; i < channels.length; i++) {
const channel = channels[i];
if (channel.type !== Constants.DM_CHANNEL) {
continue;
}
const teammateId = channel.name.replace(currentUserId, '').replace('__', '');
const isVisible = getBool(state, Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, teammateId);
if (!isVisible) {
const member = getMyChannelMember(state, channel.id);
if (!member || member.mention_count === 0) {
continue;
}