forked from Ivasoft/mattermost-mobile
* add remote action updateChannelNotifyProps * Squashed commit of the following: commitf093cd3409Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Mon May 2 12:12:43 2022 +0400 revert changes made to the ephemeral store commitaabe8bd17eMerge:18df47210ee01febbbAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Mon May 2 12:09:50 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commit18df472108Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Mon May 2 12:04:53 2022 +0400 fix timer not stopping commit5910238aaaAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 18:19:18 2022 +0400 style fix commitdef4ad4cfdAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 14:36:36 2022 +0400 eslint fix commit99fa65e780Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 14:18:03 2022 +0400 fix styling commitcf335e28b0Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 13:54:05 2022 +0400 fix layoutAnimation commitd1dacbba73Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 13:43:04 2022 +0400 add exitingg layoutAnimation commitbb1156c3daAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 13:26:37 2022 +0400 add entering layoutAnimation commit36d7286acdMerge:177281fbe22a173ec9Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 11:41:30 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commit177281fbebAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 11:41:06 2022 +0400 cancelled timers on panning start commit6925cf59aaMerge:e294a3a19dad63b87bAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 17:36:11 2022 +0400 rebasing commite294a3a199Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 17:14:33 2022 +0400 dismiss overlay on tabPress commit9a57a0866fAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 16:59:07 2022 +0400 dismiss overlay on tabPress commitc7eef4b304Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 15:55:33 2022 +0400 dismiss overlay on navigating away commit58a364171eAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 15:25:27 2022 +0400 dismiss overlay on navigating away commit3c53e7d6a7Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 13:42:10 2022 +0400 checks for ongoing animation commite62a4ee2a2Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 13:14:39 2022 +0400 removed toast keyword commitbc014b86e9Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 12:54:55 2022 +0400 PanGesture- fine tuning the animation PanGesture- wip commit8f675566e7Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 12:09:35 2022 +0400 PanGesture- wip commiteb2a63c75fAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed Apr 27 11:17:13 2022 -0400 snack positioning and touches commit6db7f0e0e7Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 27 16:43:47 2022 +0400 using EphemeralStore and listeners to discard overlays commit99a9a52789Merge:5237401f5776f56efbAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 27 14:51:32 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commit5237401f52Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 27 13:16:47 2022 +0400 able to touch through on iOS commit7dc5c5c39eAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Tue Apr 26 15:17:53 2022 +0400 adding PanGesture adding PanGesture- wip PanGesture- wip commit772654f7e5Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 21 13:57:42 2022 +0400 update message to text commit53c7ca68baAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 21 13:40:30 2022 +0400 adjust width commit0c20bd7e73Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 18:05:44 2022 +0400 changed location to sourceScreen in post.tsx commitefbccbb710Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 18:04:19 2022 +0400 removed space commitcc400482bdAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 18:01:23 2022 +0400 corrections from reviews commit4204b6c656Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 14:47:52 2022 +0400 Update en.json commit80f6d675f5Merge:c59a2cfc0c1e71b09cAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 14:27:33 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commitc59a2cfc05Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 13:58:22 2022 +0400 removed offSetY commita65af7057bAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 12:24:02 2022 +0400 styling tablet wip tablet portrait commit3ef280c80cAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Tue Apr 19 16:10:37 2022 +0400 styling mobile wip * Squashed commit of the following: commitab09b39c77Merge:038476c01362db9d98Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu May 5 15:06:12 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commit038476c01aAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu May 5 15:05:24 2022 +0400 bumping the toast vertically by 4px commit362db9d98dAuthor: Shaz MJ <shaz.amjad@mattermost.com> Date: Thu May 5 11:17:33 2022 +1000 Moves collapse animation to FlatList, updates timings (#6220) * Moves collapse animation to FlatList, updates timings * dev review * filters unreads from other categories & removes duplicate Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> commit14abe4d2acAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 17:26:32 2022 -0400 Remove jcenter (#6226) commitc8e46607b7Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 13:13:23 2022 -0400 upgrade exoplayer commit32fd8e3cdaAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 12:15:13 2022 -0400 Add ellipsis to server displayName & url (#6223) commitabc5dc4bc3Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:55:51 2022 -0400 Fix GM display name (#6215) commitecfbb934a8Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:51:14 2022 -0400 [Gekidou] Exclude muted channels from unread badges (#6208) * Exclude muted channels from unread badges * Gekidou unreads mention fix (#6221) * Removes muted channels without mentions from grouped unreads * show channel if unread and have no mentions when unread up top Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Shaz MJ <shaz.amjad@mattermost.com> commit588491f582Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:32:43 2022 -0400 Fix alignment of custom status (#6211) commit4fc077caefAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:13:17 2022 -0400 Fetch missing custom emojis (#6216) commit3aa0425fddAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:12:37 2022 -0400 Preserve notifications when tapping or clearing notifications from a channel (#6209) commitbd50422167Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 17:26:35 2022 -0400 Hide archive channels in channel list (#6214) commit43c43e50d4Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 14:43:55 2022 -0400 Do not set new line message indicator on own posts (#6206) commitf973ac8016Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 14:29:37 2022 -0400 [Gekidou] Find channels (remote) (#6203) * Display local results * Fix queryPreferencesByCategoryAndName to observeWithColumns value * Find channels (remote) * ux feedback review * dev review * dev review 2 * Fetch deleted channels from other teams commitbb42339c42Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 11:58:47 2022 -0400 Increase tap area of the + button on home screen (#6207) commit02b4295464Author: Daniel Espino García <larkox@gmail.com> Date: Tue May 3 17:22:21 2022 +0200 [Gekidou] [MM-39936] Add Select Team Screen (#6180) * Add Select Team Screen * Fixes for iPhone and iPad * Fix tests * Address feedback * Fix tests * Theme illustration * Address feedback and fixes * Remove database warnings by avoiding recalculations on repeated events. * Address feedback * Remove unneeded catch Co-authored-by: Daniel Espino <danielespino@MacBook-Pro-de-Daniel.local> commit2376dc934cAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 08:54:13 2022 -0400 Fix Back button position in Navigation Header (#6204) commitf093cd3409Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Mon May 2 12:12:43 2022 +0400 revert changes made to the ephemeral store commitaabe8bd17eMerge:18df47210ee01febbbAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Mon May 2 12:09:50 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commit18df472108Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Mon May 2 12:04:53 2022 +0400 fix timer not stopping commit5910238aaaAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 18:19:18 2022 +0400 style fix commitdef4ad4cfdAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 14:36:36 2022 +0400 eslint fix commit99fa65e780Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 14:18:03 2022 +0400 fix styling commitcf335e28b0Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 13:54:05 2022 +0400 fix layoutAnimation commitd1dacbba73Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 13:43:04 2022 +0400 add exitingg layoutAnimation commitbb1156c3daAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 13:26:37 2022 +0400 add entering layoutAnimation commit36d7286acdMerge:177281fbe22a173ec9Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 11:41:30 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commit177281fbebAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Fri Apr 29 11:41:06 2022 +0400 cancelled timers on panning start commit6925cf59aaMerge:e294a3a19dad63b87bAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 17:36:11 2022 +0400 rebasing commite294a3a199Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 17:14:33 2022 +0400 dismiss overlay on tabPress commit9a57a0866fAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 16:59:07 2022 +0400 dismiss overlay on tabPress commitc7eef4b304Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 15:55:33 2022 +0400 dismiss overlay on navigating away commit58a364171eAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 15:25:27 2022 +0400 dismiss overlay on navigating away commit3c53e7d6a7Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 13:42:10 2022 +0400 checks for ongoing animation commite62a4ee2a2Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 13:14:39 2022 +0400 removed toast keyword commitbc014b86e9Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 12:54:55 2022 +0400 PanGesture- fine tuning the animation PanGesture- wip commit8f675566e7Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 28 12:09:35 2022 +0400 PanGesture- wip commiteb2a63c75fAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed Apr 27 11:17:13 2022 -0400 snack positioning and touches commit6db7f0e0e7Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 27 16:43:47 2022 +0400 using EphemeralStore and listeners to discard overlays commit99a9a52789Merge:5237401f5776f56efbAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 27 14:51:32 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commit5237401f52Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 27 13:16:47 2022 +0400 able to touch through on iOS commit7dc5c5c39eAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Tue Apr 26 15:17:53 2022 +0400 adding PanGesture adding PanGesture- wip PanGesture- wip commit772654f7e5Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 21 13:57:42 2022 +0400 update message to text commit53c7ca68baAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu Apr 21 13:40:30 2022 +0400 adjust width commit0c20bd7e73Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 18:05:44 2022 +0400 changed location to sourceScreen in post.tsx commitefbccbb710Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 18:04:19 2022 +0400 removed space commitcc400482bdAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 18:01:23 2022 +0400 corrections from reviews commit4204b6c656Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 14:47:52 2022 +0400 Update en.json commit80f6d675f5Merge:c59a2cfc0c1e71b09cAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 14:27:33 2022 +0400 Merge branch 'gekidou' into gekidou-snack-bars commitc59a2cfc05Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 13:58:22 2022 +0400 removed offSetY commita65af7057bAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Wed Apr 20 12:24:02 2022 +0400 styling tablet wip tablet portrait commit3ef280c80cAuthor: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Tue Apr 19 16:10:37 2022 +0400 styling mobile wip * minor clean up * Squashed commit of the following: commitc7c00b8316Author: Elias Nahum <nahumhbl@gmail.com> Date: Thu May 5 18:25:46 2022 -0400 Ensure posts are not covered by the post draft on channel switch commit58719c82dcAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Thu May 5 14:09:30 2022 -0400 fix flip of post list (#6234) commit9d3c7c9496Author: Joseph Baylon <joseph.baylon@mattermost.com> Date: Thu May 5 10:04:33 2022 -0700 Detox/E2E: Messaging e2e tests in Gekidou (#6228) commit1760b75dbfAuthor: Anurag Shivarathri <anurag6713@gmail.com> Date: Thu May 5 21:03:09 2022 +0530 [Gekidou] [MM-43973] Thread footer for recent mentions (#6225) * Displaying thread footer * Participants can be empty * Update thread.ts commit83c2cfff97Author: Avinash Lingaloo <avinashlng1080@gmail.com> Date: Thu May 5 18:00:32 2022 +0400 MM-41532 Gekidou Snack Bars (#6181) * styling mobile wip * styling tablet wip tablet portrait * removed offSetY * Update en.json * corrections from reviews * removed space * changed location to sourceScreen in post.tsx * adjust width * update message to text * adding PanGesture adding PanGesture- wip PanGesture- wip * able to touch through on iOS * using EphemeralStore and listeners to discard overlays * snack positioning and touches * PanGesture- wip * PanGesture- fine tuning the animation PanGesture- wip * removed toast keyword * checks for ongoing animation * dismiss overlay on navigating away * dismiss overlay on navigating away * dismiss overlay on tabPress * dismiss overlay on tabPress * cancelled timers on panning start * add entering layoutAnimation * add exitingg layoutAnimation * fix layoutAnimation * fix styling * eslint fix * style fix * fix timer not stopping * revert changes made to the ephemeral store * bumping the toast vertically by 4px Co-authored-by: Elias Nahum <nahumhbl@gmail.com> commit2deb2e01e0Author: Anurag Shivarathri <anurag6713@gmail.com> Date: Thu May 5 18:36:18 2022 +0530 [Gekidou][MM-43870, MM-43896, MM-43898, MM-43902, MM-43903] CRT related bug fixes (#6205) * Fixes * Updated snapshot * Excluding current user from getting updated * Doesn't handle users if it's empty Co-authored-by: Elias Nahum <nahumhbl@gmail.com> commit251ef0992bAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Thu May 5 08:53:27 2022 -0400 Fix create direct message styles (#6224) commit5620a50975Author: Elias Nahum <nahumhbl@gmail.com> Date: Thu May 5 08:53:02 2022 -0400 Fix channel item with long name and badge (#6222) commita0d2f33b2fAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Thu May 5 08:47:09 2022 -0400 Dismiss post options before executing action (#6227) commitc4e1b4ad3eAuthor: Shaz MJ <shaz.amjad@mattermost.com> Date: Thu May 5 22:45:50 2022 +1000 Fixes grouped unread sorting (#6230) * Fixes grouped unread sorting * Type fix commit362db9d98dAuthor: Shaz MJ <shaz.amjad@mattermost.com> Date: Thu May 5 11:17:33 2022 +1000 Moves collapse animation to FlatList, updates timings (#6220) * Moves collapse animation to FlatList, updates timings * dev review * filters unreads from other categories & removes duplicate Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> commit14abe4d2acAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 17:26:32 2022 -0400 Remove jcenter (#6226) commitc8e46607b7Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 13:13:23 2022 -0400 upgrade exoplayer commit32fd8e3cdaAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 12:15:13 2022 -0400 Add ellipsis to server displayName & url (#6223) commitabc5dc4bc3Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:55:51 2022 -0400 Fix GM display name (#6215) commitecfbb934a8Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:51:14 2022 -0400 [Gekidou] Exclude muted channels from unread badges (#6208) * Exclude muted channels from unread badges * Gekidou unreads mention fix (#6221) * Removes muted channels without mentions from grouped unreads * show channel if unread and have no mentions when unread up top Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Shaz MJ <shaz.amjad@mattermost.com> commit588491f582Author: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:32:43 2022 -0400 Fix alignment of custom status (#6211) commit4fc077caefAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:13:17 2022 -0400 Fetch missing custom emojis (#6216) commit3aa0425fddAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Wed May 4 09:12:37 2022 -0400 Preserve notifications when tapping or clearing notifications from a channel (#6209) commitbd50422167Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 17:26:35 2022 -0400 Hide archive channels in channel list (#6214) commit43c43e50d4Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 14:43:55 2022 -0400 Do not set new line message indicator on own posts (#6206) commitf973ac8016Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 14:29:37 2022 -0400 [Gekidou] Find channels (remote) (#6203) * Display local results * Fix queryPreferencesByCategoryAndName to observeWithColumns value * Find channels (remote) * ux feedback review * dev review * dev review 2 * Fetch deleted channels from other teams commitbb42339c42Author: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 11:58:47 2022 -0400 Increase tap area of the + button on home screen (#6207) commit02b4295464Author: Daniel Espino García <larkox@gmail.com> Date: Tue May 3 17:22:21 2022 +0200 [Gekidou] [MM-39936] Add Select Team Screen (#6180) * Add Select Team Screen * Fixes for iPhone and iPad * Fix tests * Address feedback * Fix tests * Theme illustration * Address feedback and fixes * Remove database warnings by avoiding recalculations on repeated events. * Address feedback * Remove unneeded catch Co-authored-by: Daniel Espino <danielespino@MacBook-Pro-de-Daniel.local> commit2376dc934cAuthor: Elias Nahum <nahumhbl@gmail.com> Date: Tue May 3 08:54:13 2022 -0400 Fix Back button position in Navigation Header (#6204) * snack bar with undo option * fix react error * implement onAction correctly * implemented pessimistic approach * fix ts issue * Move toggleMuteChannel to remote actions Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
135 lines
5.1 KiB
TypeScript
135 lines
5.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {IntlShape} from 'react-intl';
|
|
|
|
import {Channel, General, Permissions} from '@constants';
|
|
import {t, DEFAULT_LOCALE} from '@i18n';
|
|
import {hasPermission} from '@utils/role';
|
|
|
|
import {generateId} from '../general';
|
|
import {cleanUpUrlable} from '../url';
|
|
|
|
import type ChannelModel from '@typings/database/models/servers/channel';
|
|
|
|
export function getDirectChannelName(id: string, otherId: string): string {
|
|
let handle;
|
|
|
|
if (otherId > id) {
|
|
handle = id + '__' + otherId;
|
|
} else {
|
|
handle = otherId + '__' + id;
|
|
}
|
|
|
|
return handle;
|
|
}
|
|
|
|
export function isDMorGM(channel: Channel | ChannelModel): boolean {
|
|
const directTypes: string[] = [General.GM_CHANNEL, General.DM_CHANNEL];
|
|
return directTypes.includes(channel.type);
|
|
}
|
|
|
|
export function selectDefaultChannelForTeam<T extends Channel|ChannelModel>(channels: T[], memberships: ChannelMembership[], teamId: string, roles?: Role[], locale = DEFAULT_LOCALE) {
|
|
let channel: T|undefined;
|
|
let canIJoinPublicChannelsInTeam = false;
|
|
|
|
if (roles) {
|
|
canIJoinPublicChannelsInTeam = hasPermission(roles, Permissions.JOIN_PUBLIC_CHANNELS, true);
|
|
}
|
|
const defaultChannel = channels?.find((c) => c.name === General.DEFAULT_CHANNEL);
|
|
const membershipIds = new Set(memberships.map((m) => m.channel_id));
|
|
const iAmMemberOfTheTeamDefaultChannel = Boolean(defaultChannel && membershipIds.has(defaultChannel.id));
|
|
const myFirstTeamChannel = channels?.filter((c) =>
|
|
(('team_id' in c) ? c.team_id : c.teamId) === teamId &&
|
|
c.type === General.OPEN_CHANNEL &&
|
|
membershipIds.has(c.id),
|
|
).sort(sortChannelsByDisplayName.bind(null, locale))[0];
|
|
|
|
if (iAmMemberOfTheTeamDefaultChannel || canIJoinPublicChannelsInTeam) {
|
|
channel = defaultChannel;
|
|
} else {
|
|
channel = myFirstTeamChannel || defaultChannel;
|
|
}
|
|
|
|
return channel;
|
|
}
|
|
|
|
export function sortChannelsByDisplayName<T extends Channel|ChannelModel>(locale: string, a: T, b: T): number {
|
|
// if both channels have the display_name defined
|
|
const aDisplayName = 'display_name' in a ? a.display_name : a.displayName;
|
|
const bDisplayName = 'display_name' in b ? b.display_name : b.displayName;
|
|
if (aDisplayName && bDisplayName && aDisplayName !== bDisplayName) {
|
|
return aDisplayName.toLowerCase().localeCompare(bDisplayName.toLowerCase(), locale, {numeric: true});
|
|
}
|
|
|
|
return a.name.toLowerCase().localeCompare(b.name.toLowerCase(), locale, {numeric: true});
|
|
}
|
|
|
|
export function sortChannelsModelByDisplayName(locale: string, a: ChannelModel, b: ChannelModel): number {
|
|
// if both channels have the display_name defined
|
|
if (a.displayName && b.displayName && a.displayName !== b.displayName) {
|
|
return a.displayName.toLowerCase().localeCompare(b.displayName.toLowerCase(), locale, {numeric: true});
|
|
}
|
|
|
|
return a.name.toLowerCase().localeCompare(b.name.toLowerCase(), locale, {numeric: true});
|
|
}
|
|
|
|
const displayNameValidationMessages = {
|
|
display_name_required: {
|
|
id: t('mobile.rename_channel.display_name_required'),
|
|
defaultMessage: 'Channel name is required',
|
|
},
|
|
display_name_maxLength: {
|
|
id: t('mobile.rename_channel.display_name_maxLength'),
|
|
defaultMessage: 'Channel name must be less than {maxLength, number} characters',
|
|
},
|
|
display_name_minLength: {
|
|
id: t('mobile.rename_channel.display_name_minLength'),
|
|
defaultMessage: 'Channel name must be {minLength, number} or more characters',
|
|
},
|
|
};
|
|
|
|
export const validateDisplayName = (intl: IntlShape, displayName: string): {error: string} => {
|
|
let errorMessage;
|
|
switch (true) {
|
|
case !displayName:
|
|
errorMessage = intl.formatMessage(displayNameValidationMessages.display_name_required);
|
|
break;
|
|
case displayName.length > Channel.MAX_CHANNEL_NAME_LENGTH:
|
|
errorMessage = intl.formatMessage(
|
|
displayNameValidationMessages.display_name_maxLength,
|
|
{maxLength: Channel.MAX_CHANNEL_NAME_LENGTH});
|
|
break;
|
|
case displayName.length < Channel.MIN_CHANNEL_NAME_LENGTH:
|
|
errorMessage = intl.formatMessage(
|
|
displayNameValidationMessages.display_name_minLength,
|
|
{minLength: Channel.MIN_CHANNEL_NAME_LENGTH});
|
|
break;
|
|
|
|
default:
|
|
errorMessage = '';
|
|
}
|
|
return {error: errorMessage};
|
|
};
|
|
|
|
export function generateChannelNameFromDisplayName(displayName: string) {
|
|
let name = cleanUpUrlable(displayName);
|
|
if (name === '') {
|
|
name = generateId();
|
|
}
|
|
return name;
|
|
}
|
|
|
|
export function compareNotifyProps(propsA: Partial<ChannelNotifyProps>, propsB: Partial<ChannelNotifyProps>): boolean {
|
|
if (
|
|
propsA.desktop !== propsB.desktop ||
|
|
propsA.email !== propsB.email ||
|
|
propsA.mark_unread !== propsB.mark_unread ||
|
|
propsA.push !== propsB.push ||
|
|
propsA.ignore_channel_mentions !== propsB.ignore_channel_mentions
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|