diff --git a/app/actions/remote/command.ts b/app/actions/remote/command.ts index 9fb07280b8..bf50cd3288 100644 --- a/app/actions/remote/command.ts +++ b/app/actions/remote/command.ts @@ -6,7 +6,7 @@ import {Alert} from 'react-native'; import {showPermalink} from '@actions/remote/permalink'; import {Client} from '@client/rest'; -import DeepLinkTypes from '@constants/deep_linking'; +import DeepLinkType from '@constants/deep_linking'; import DatabaseManager from '@database/manager'; import IntegrationsManager from '@managers/integrations_manager'; import NetworkManager from '@managers/network_manager'; @@ -140,17 +140,17 @@ export const handleGotoLocation = async (serverUrl: string, intl: IntlShape, loc if (match && linkServerUrl) { switch (match.type) { - case DeepLinkTypes.CHANNEL: { + case DeepLinkType.Channel: { const data = match.data as DeepLinkChannel; switchToChannelByName(linkServerUrl, data.channelName, data.teamName, DraftUtils.errorBadChannel, intl); break; } - case DeepLinkTypes.PERMALINK: { + case DeepLinkType.Permalink: { const data = match.data as DeepLinkPermalink; showPermalink(linkServerUrl, data.teamName, data.postId, intl); break; } - case DeepLinkTypes.DMCHANNEL: { + case DeepLinkType.DirectMessage: { const data = match.data as DeepLinkDM; if (!data.userName) { DraftUtils.errorUnkownUser(intl); @@ -171,7 +171,7 @@ export const handleGotoLocation = async (serverUrl: string, intl: IntlShape, loc makeDirectChannel(linkServerUrl, user.id, displayUsername(user, intl.locale, await getTeammateNameDisplay(database)), true); break; } - case DeepLinkTypes.GROUPCHANNEL: { + case DeepLinkType.GroupMessage: { const data = match.data as DeepLinkGM; if (!data.channelId) { DraftUtils.errorBadChannel(intl); @@ -181,7 +181,7 @@ export const handleGotoLocation = async (serverUrl: string, intl: IntlShape, loc switchToChannelById(linkServerUrl, data.channelId); break; } - case DeepLinkTypes.PLUGIN: { + case DeepLinkType.Plugin: { const data = match.data as DeepLinkPlugin; showModal('PluginInternal', data.id, {link: location}); break; diff --git a/app/actions/remote/groups.ts b/app/actions/remote/groups.ts index 62b054193e..f0919f39e3 100644 --- a/app/actions/remote/groups.ts +++ b/app/actions/remote/groups.ts @@ -1,10 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {getChannelById} from '@app/queries/servers/channel'; import {Client} from '@client/rest'; import DatabaseManager from '@database/manager'; import NetworkManager from '@managers/network_manager'; +import {getChannelById} from '@queries/servers/channel'; import {getTeamById} from '@queries/servers/team'; import {forceLogoutIfNecessary} from './session'; diff --git a/app/client/rest/base.ts b/app/client/rest/base.ts index cda97ec367..0c800853ee 100644 --- a/app/client/rest/base.ts +++ b/app/client/rest/base.ts @@ -3,8 +3,7 @@ import {DeviceEventEmitter} from 'react-native'; -import {Events} from '@constants'; -import Calls from '@constants/calls'; +import {Events, Calls} from '@constants'; import {t} from '@i18n'; import {setServerCredentials} from '@init/credentials'; import {Analytics, create} from '@managers/analytics'; diff --git a/app/components/autocomplete/slash_suggestion/app_slash_suggestion/app_slash_suggestion.tsx b/app/components/autocomplete/slash_suggestion/app_slash_suggestion/app_slash_suggestion.tsx index 7a79f7c2d2..b5fa47358f 100644 --- a/app/components/autocomplete/slash_suggestion/app_slash_suggestion/app_slash_suggestion.tsx +++ b/app/components/autocomplete/slash_suggestion/app_slash_suggestion/app_slash_suggestion.tsx @@ -12,13 +12,14 @@ import {COMMAND_SUGGESTION_CHANNEL, COMMAND_SUGGESTION_USER} from '@constants/ap import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import analytics from '@managers/analytics'; -import ChannelModel from '@typings/database/models/servers/channel'; -import UserModel from '@typings/database/models/servers/user'; import {makeStyleSheetFromTheme} from '@utils/theme'; import {AppCommandParser, ExtendedAutocompleteSuggestion} from '../app_command_parser/app_command_parser'; import SlashSuggestionItem from '../slash_suggestion_item'; +import type ChannelModel from '@typings/database/models/servers/channel'; +import type UserModel from '@typings/database/models/servers/user'; + export type Props = { currentTeamId: string; isSearch?: boolean; diff --git a/app/components/channel_item/index.ts b/app/components/channel_item/index.ts index 318a69a98c..91dfc00fc0 100644 --- a/app/components/channel_item/index.ts +++ b/app/components/channel_item/index.ts @@ -13,12 +13,12 @@ import {withServerUrl} from '@context/server'; import {observeMyChannel} from '@queries/servers/channel'; import {queryDraft} from '@queries/servers/drafts'; import {observeCurrentChannelId, observeCurrentUserId} from '@queries/servers/system'; -import ChannelModel from '@typings/database/models/servers/channel'; -import MyChannelModel from '@typings/database/models/servers/my_channel'; import ChannelItem from './channel_item'; import type {WithDatabaseArgs} from '@typings/database/database'; +import type ChannelModel from '@typings/database/models/servers/channel'; +import type MyChannelModel from '@typings/database/models/servers/my_channel'; type EnhanceProps = WithDatabaseArgs & { channel: ChannelModel; diff --git a/app/components/markdown/markdown_image/index.tsx b/app/components/markdown/markdown_image/index.tsx index c647e86425..739628bf3d 100644 --- a/app/components/markdown/markdown_image/index.tsx +++ b/app/components/markdown/markdown_image/index.tsx @@ -31,6 +31,8 @@ import {getMarkdownImageSize} from '@utils/markdown'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {normalizeProtocol, tryOpenURL} from '@utils/url'; +import type {GalleryItemType} from '@typings/screens/gallery'; + type MarkdownImageProps = { disabled?: boolean; errorTextStyle: StyleProp; diff --git a/app/components/markdown/markdown_link/markdown_link.tsx b/app/components/markdown/markdown_link/markdown_link.tsx index 9754d35c31..7eed3187a0 100644 --- a/app/components/markdown/markdown_link/markdown_link.tsx +++ b/app/components/markdown/markdown_link/markdown_link.tsx @@ -12,7 +12,7 @@ import urlParse from 'url-parse'; import {switchToChannelByName} from '@actions/remote/channel'; import {showPermalink} from '@actions/remote/permalink'; import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item'; -import DeepLinkTypes from '@constants/deep_linking'; +import DeepLinkType from '@constants/deep_linking'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import {bottomSheet, dismissBottomSheet} from '@screens/navigation'; @@ -68,9 +68,9 @@ const MarkdownLink = ({children, experimentalNormalizeMarkdownLinks, href, siteU const match: DeepLinkWithData | null = matchDeepLink(url, serverUrl, siteURL); if (match && match.data?.teamName) { - if (match.type === DeepLinkTypes.CHANNEL) { + if (match.type === DeepLinkType.Channel) { await switchToChannelByName(serverUrl, (match?.data as DeepLinkChannel).channelName, match.data?.teamName, errorBadChannel, intl); - } else if (match.type === DeepLinkTypes.PERMALINK) { + } else if (match.type === DeepLinkType.Permalink) { showPermalink(serverUrl, match.data.teamName, (match.data as DeepLinkPermalink).postId, intl); } } else { diff --git a/app/components/markdown/markdown_table/index.tsx b/app/components/markdown/markdown_table/index.tsx index 431515071a..2f50b1366a 100644 --- a/app/components/markdown/markdown_table/index.tsx +++ b/app/components/markdown/markdown_table/index.tsx @@ -8,8 +8,7 @@ import LinearGradient from 'react-native-linear-gradient'; import CompassIcon from '@components/compass_icon'; import {CELL_MAX_WIDTH, CELL_MIN_WIDTH} from '@components/markdown/markdown_table_cell'; -import {Screens} from '@constants'; -import DeviceTypes from '@constants/device'; +import {Screens, Device} from '@constants'; import {goToScreen} from '@screens/navigation'; import {preventDoubleTap} from '@utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; @@ -182,7 +181,7 @@ class MarkdownTable extends PureComponent 1 && numColumns < 4 && !DeviceTypes.IS_TABLET) { + if (!isFullView && numColumns > 1 && numColumns < 4 && !Device.IS_TABLET) { return true; } @@ -194,7 +193,7 @@ class MarkdownTable extends PureComponent= 3 && numColumns <= 4 && !DeviceTypes.IS_TABLET) { + if (isFullView && numColumns >= 3 && numColumns <= 4 && !Device.IS_TABLET) { return true; } diff --git a/app/components/markdown/markdown_table_image/index.tsx b/app/components/markdown/markdown_table_image/index.tsx index b802e9a385..2558a19e71 100644 --- a/app/components/markdown/markdown_table_image/index.tsx +++ b/app/components/markdown/markdown_table_image/index.tsx @@ -14,6 +14,8 @@ import {fileToGalleryItem, openGalleryAtIndex} from '@utils/gallery'; import {generateId} from '@utils/general'; import {calculateDimensions, isGifTooLarge} from '@utils/images'; +import type {GalleryItemType} from '@typings/screens/gallery'; + type MarkdownTableImageProps = { disabled?: boolean; imagesMetadata: Record; diff --git a/app/components/post_list/post/body/content/embedded_bindings/menu_binding/index.tsx b/app/components/post_list/post/body/content/embedded_bindings/menu_binding/index.tsx index 5fa281d840..7a36f6e77f 100644 --- a/app/components/post_list/post/body/content/embedded_bindings/menu_binding/index.tsx +++ b/app/components/post_list/post/body/content/embedded_bindings/menu_binding/index.tsx @@ -12,10 +12,10 @@ import AutocompleteSelector from '@components/autocomplete_selector'; import {AppBindingLocations, AppCallResponseTypes} from '@constants/apps'; import {useServerUrl} from '@context/server'; import {observeCurrentTeamId} from '@queries/servers/system'; -import {WithDatabaseArgs} from '@typings/database/database'; import {createCallContext} from '@utils/apps'; import {logDebug} from '@utils/log'; +import type {WithDatabaseArgs} from '@typings/database/database'; import type ChannelModel from '@typings/database/models/servers/channel'; import type PostModel from '@typings/database/models/servers/post'; diff --git a/app/components/post_list/post/body/content/image_preview/image_preview.tsx b/app/components/post_list/post/body/content/image_preview/image_preview.tsx index 1b536dd3c9..8285e40e22 100644 --- a/app/components/post_list/post/body/content/image_preview/image_preview.tsx +++ b/app/components/post_list/post/body/content/image_preview/image_preview.tsx @@ -19,6 +19,8 @@ import {calculateDimensions, getViewPortWidth, isGifTooLarge} from '@utils/image import {changeOpacity} from '@utils/theme'; import {extractFilenameFromUrl, isImageLink, isValidUrl} from '@utils/url'; +import type {GalleryItemType} from '@typings/screens/gallery'; + type ImagePreviewProps = { expandedLink?: string; isReplyPost: boolean; diff --git a/app/components/post_list/post/body/content/message_attachments/attachment_image/index.tsx b/app/components/post_list/post/body/content/message_attachments/attachment_image/index.tsx index fb3f5114a7..321c1af05f 100644 --- a/app/components/post_list/post/body/content/message_attachments/attachment_image/index.tsx +++ b/app/components/post_list/post/body/content/message_attachments/attachment_image/index.tsx @@ -17,6 +17,8 @@ import {isGifTooLarge, calculateDimensions, getViewPortWidth} from '@utils/image import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {extractFilenameFromUrl, isValidUrl} from '@utils/url'; +import type {GalleryItemType} from '@typings/screens/gallery'; + const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { return { attachmentMargin: { diff --git a/app/components/post_list/post/body/content/opengraph/opengraph_image/index.tsx b/app/components/post_list/post/body/content/opengraph/opengraph_image/index.tsx index cd97c81a2c..be80402004 100644 --- a/app/components/post_list/post/body/content/opengraph/opengraph_image/index.tsx +++ b/app/components/post_list/post/body/content/opengraph/opengraph_image/index.tsx @@ -17,6 +17,8 @@ import {BestImage, getNearestPoint} from '@utils/opengraph'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {extractFilenameFromUrl, isValidUrl} from '@utils/url'; +import type {GalleryItemType} from '@typings/screens/gallery'; + type OpengraphImageProps = { isReplyPost: boolean; layoutWidth?: number; diff --git a/app/constants/database.ts b/app/constants/database.ts index 31a427723e..f3c0c2f399 100644 --- a/app/constants/database.ts +++ b/app/constants/database.ts @@ -73,6 +73,18 @@ export const GLOBAL_IDENTIFIERS = { PROFILE_LONG_PRESS_TUTORIAL: 'profileLongPressTutorial', }; +export enum OperationType { + CREATE = 'CREATE', + UPDATE = 'UPDATE', + DELETE = 'DELETE', + } + +// The only two types of databases in the app +export enum DatabaseType { + DEFAULT, + SERVER, + } + export default { GLOBAL_IDENTIFIERS, MM_TABLES, diff --git a/app/constants/deep_linking.ts b/app/constants/deep_linking.ts index 06c282fe8b..61ffa56cb4 100644 --- a/app/constants/deep_linking.ts +++ b/app/constants/deep_linking.ts @@ -1,11 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -export default { - CHANNEL: 'channel', - DMCHANNEL: 'dmchannel', - GROUPCHANNEL: 'groupchannel', - PERMALINK: 'permalink', - PLUGIN: 'plugin', - OTHER: 'other', -}; +const DeepLinkType = { + Channel: 'channel', + DirectMessage: 'dm', + GroupMessage: 'gm', + Invalid: 'invalid', + Permalink: 'permalink', + Plugin: 'plugin', +} as const; + +export default DeepLinkType; diff --git a/app/constants/index.ts b/app/constants/index.ts index 8770e7ffe2..924a5c4fdd 100644 --- a/app/constants/index.ts +++ b/app/constants/index.ts @@ -3,6 +3,7 @@ import ActionType from './action_type'; import Apps from './apps'; +import Calls from './calls'; import Categories from './categories'; import Channel from './channel'; import Config from './config'; @@ -15,6 +16,7 @@ import Events from './events'; import Files from './files'; import General from './general'; import Integrations from './integrations'; +import Launch from './launch'; import List from './list'; import Navigation from './navigation'; import Network from './network'; @@ -36,6 +38,7 @@ import WebsocketEvents from './websocket'; export { ActionType, Apps, + Calls, Categories, Channel, Config, @@ -48,6 +51,7 @@ export { Files, General, Integrations, + Launch, List, Navigation, Network, diff --git a/app/constants/launch.ts b/app/constants/launch.ts new file mode 100644 index 0000000000..d31bc52bcf --- /dev/null +++ b/app/constants/launch.ts @@ -0,0 +1,12 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +const LaunchType = { + AddServer: 'add-server', + Normal: 'normal', + DeepLink: 'deeplink', + Notification: 'notification', + Upgrade: 'upgrade', +} as const; + +export default LaunchType; diff --git a/app/context/gallery/index.tsx b/app/context/gallery/index.tsx index 31759bc0a0..c766f1e93c 100644 --- a/app/context/gallery/index.tsx +++ b/app/context/gallery/index.tsx @@ -4,6 +4,8 @@ import React, {useEffect, useLayoutEffect} from 'react'; import Animated, {makeMutable, runOnUI} from 'react-native-reanimated'; +import type {GalleryManagerSharedValues} from '@typings/screens/gallery'; + export interface GalleryManagerItem { index: number; ref: React.RefObject; diff --git a/app/database/manager/__mocks__/index.ts b/app/database/manager/__mocks__/index.ts index 5dfb85569d..1aa13afcd2 100644 --- a/app/database/manager/__mocks__/index.ts +++ b/app/database/manager/__mocks__/index.ts @@ -7,7 +7,7 @@ import logger from '@nozbe/watermelondb/utils/common/logger'; import {DeviceEventEmitter, Platform} from 'react-native'; import FileSystem from 'react-native-fs'; -import {MIGRATION_EVENTS, MM_TABLES} from '@constants/database'; +import {DatabaseType, MIGRATION_EVENTS, MM_TABLES} from '@constants/database'; import AppDatabaseMigrations from '@database/migration/app'; import ServerDatabaseMigrations from '@database/migration/server'; import {InfoModel, GlobalModel, ServersModel} from '@database/models/app'; @@ -22,7 +22,6 @@ import ServerDataOperator from '@database/operator/server_data_operator'; import {schema as appSchema} from '@database/schema/app'; import {serverSchema} from '@database/schema/server'; import {queryActiveServer, queryServer, queryServerByIdentifier} from '@queries/app/servers'; -import {DatabaseType} from '@typings/database/enums'; import {deleteIOSDatabase} from '@utils/mattermost_managed'; import {hashCode} from '@utils/security'; import {removeProtocol} from '@utils/url'; diff --git a/app/database/manager/index.ts b/app/database/manager/index.ts index d2122a2280..d3c63ba8b7 100644 --- a/app/database/manager/index.ts +++ b/app/database/manager/index.ts @@ -8,7 +8,7 @@ import {DeviceEventEmitter, Platform} from 'react-native'; import DeviceInfo from 'react-native-device-info'; import FileSystem from 'react-native-fs'; -import {MIGRATION_EVENTS, MM_TABLES} from '@constants/database'; +import {DatabaseType, MIGRATION_EVENTS, MM_TABLES} from '@constants/database'; import AppDatabaseMigrations from '@database/migration/app'; import ServerDatabaseMigrations from '@database/migration/server'; import {InfoModel, GlobalModel, ServersModel} from '@database/models/app'; @@ -23,7 +23,6 @@ import ServerDataOperator from '@database/operator/server_data_operator'; import {schema as appSchema} from '@database/schema/app'; import {serverSchema} from '@database/schema/server'; import {queryActiveServer, queryServer, queryServerByIdentifier} from '@queries/app/servers'; -import {DatabaseType} from '@typings/database/enums'; import {emptyFunction} from '@utils/general'; import {logDebug, logError} from '@utils/log'; import {deleteIOSDatabase, getIOSAppGroupDetails} from '@utils/mattermost_managed'; diff --git a/app/database/manager/test_manual.ts b/app/database/manager/test_manual.ts index fc98a8cbbf..03f954c377 100644 --- a/app/database/manager/test_manual.ts +++ b/app/database/manager/test_manual.ts @@ -4,8 +4,7 @@ import {Q} from '@nozbe/watermelondb'; import {Platform} from 'react-native'; -import {MM_TABLES} from '@constants/database'; -import {DatabaseType} from '@typings/database/enums'; +import {DatabaseType, MM_TABLES} from '@constants/database'; import {getIOSAppGroupDetails} from '@utils/mattermost_managed'; import DatabaseManager from './index'; diff --git a/app/database/models/app/info.ts b/app/database/models/app/info.ts index 490210ebfd..3b9bedd7a0 100644 --- a/app/database/models/app/info.ts +++ b/app/database/models/app/info.ts @@ -5,7 +5,8 @@ import {Model} from '@nozbe/watermelondb'; import {field} from '@nozbe/watermelondb/decorators'; import {MM_TABLES} from '@constants/database'; -import InfoModelInterface from '@typings/database/models/app/info'; + +import type InfoModelInterface from '@typings/database/models/app/info'; const {INFO} = MM_TABLES.APP; diff --git a/app/database/models/server/my_channel.ts b/app/database/models/server/my_channel.ts index b650206134..21ad87db9c 100644 --- a/app/database/models/server/my_channel.ts +++ b/app/database/models/server/my_channel.ts @@ -6,10 +6,10 @@ import {field, immutableRelation} from '@nozbe/watermelondb/decorators'; import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; -import MyChannelSettingsModel from '@typings/database/models/servers/my_channel_settings'; import type ChannelModel from '@typings/database/models/servers/channel'; import type MyChannelModelInterface from '@typings/database/models/servers/my_channel'; +import type MyChannelSettingsModel from '@typings/database/models/servers/my_channel_settings'; const {CATEGORY_CHANNEL, CHANNEL, MY_CHANNEL, MY_CHANNEL_SETTINGS} = MM_TABLES.SERVER; diff --git a/app/database/models/server/user.ts b/app/database/models/server/user.ts index adf41e797b..efaca8ef96 100644 --- a/app/database/models/server/user.ts +++ b/app/database/models/server/user.ts @@ -6,7 +6,6 @@ import {children, field, json} from '@nozbe/watermelondb/decorators'; import Model, {Associations} from '@nozbe/watermelondb/Model'; import {MM_TABLES} from '@constants/database'; -import ThreadParticipantsModel from '@typings/database/models/servers/thread_participant'; import {safeParseJSON} from '@utils/helpers'; import type ChannelModel from '@typings/database/models/servers/channel'; @@ -15,6 +14,7 @@ import type PostModel from '@typings/database/models/servers/post'; import type PreferenceModel from '@typings/database/models/servers/preference'; import type ReactionModel from '@typings/database/models/servers/reaction'; import type TeamMembershipModel from '@typings/database/models/servers/team_membership'; +import type ThreadParticipantsModel from '@typings/database/models/servers/thread_participant'; import type UserModelInterface from '@typings/database/models/servers/user'; import type {UserMentionKey} from '@typings/global/markdown'; diff --git a/app/database/operator/app_data_operator/transformers/index.ts b/app/database/operator/app_data_operator/transformers/index.ts index 4ade485f02..e3f30270c6 100644 --- a/app/database/operator/app_data_operator/transformers/index.ts +++ b/app/database/operator/app_data_operator/transformers/index.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers'; -import {OperationType} from '@typings/database/enums'; import type {Model} from '@nozbe/watermelondb'; import type {TransformerArgs} from '@typings/database/database'; diff --git a/app/database/operator/app_data_operator/transformers/test.ts b/app/database/operator/app_data_operator/transformers/test.ts index 712780bb01..c86517e106 100644 --- a/app/database/operator/app_data_operator/transformers/test.ts +++ b/app/database/operator/app_data_operator/transformers/test.ts @@ -1,12 +1,12 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import DatabaseManager from '@database/manager'; import { transformInfoRecord, transformGlobalRecord, } from '@database/operator/app_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; describe('** APP DATA TRANSFORMER **', () => { beforeAll(async () => { diff --git a/app/database/operator/base_data_operator/index.ts b/app/database/operator/base_data_operator/index.ts index 631cf60e6d..430b9a2915 100644 --- a/app/database/operator/base_data_operator/index.ts +++ b/app/database/operator/base_data_operator/index.ts @@ -3,12 +3,12 @@ import {Database, Q} from '@nozbe/watermelondb'; +import {OperationType} from '@constants/database'; import { getRangeOfValues, getValidRecordsForUpdate, retrieveRecords, } from '@database/operator/utils/general'; -import {OperationType} from '@typings/database/enums'; import {logWarning} from '@utils/log'; import type {WriterInterface} from '@nozbe/watermelondb/Database'; diff --git a/app/database/operator/server_data_operator/handlers/index.test.ts b/app/database/operator/server_data_operator/handlers/index.test.ts index 9a3f3bc637..3b1fccc9a4 100644 --- a/app/database/operator/server_data_operator/handlers/index.test.ts +++ b/app/database/operator/server_data_operator/handlers/index.test.ts @@ -9,7 +9,6 @@ import { } from '@database/operator/server_data_operator/transformers/general'; import type ServerDataOperator from '..'; -import type {Model} from '@nozbe/watermelondb'; describe('*** DataOperator: Base Handlers tests ***', () => { let operator: ServerDataOperator; @@ -104,13 +103,11 @@ describe('*** DataOperator: Base Handlers tests ***', () => { expect(appDatabase).toBeTruthy(); expect(appOperator).toBeTruthy(); - const transformer = async (model: Model) => model; - await expect( operator?.handleRecords({ fieldName: 'invalidField', tableName: 'INVALID_TABLE_NAME', - transformer, + transformer: transformSystemRecord, createOrUpdateRawValues: [{id: 'tos-1', value: '1'}], prepareRecordsOnly: false, }), diff --git a/app/database/operator/server_data_operator/transformers/category.test.ts b/app/database/operator/server_data_operator/transformers/category.test.ts index 47bdac4da6..58930cbe25 100644 --- a/app/database/operator/server_data_operator/transformers/category.test.ts +++ b/app/database/operator/server_data_operator/transformers/category.test.ts @@ -1,12 +1,12 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import { transformCategoryRecord, transformCategoryChannelRecord, } from '@database/operator/server_data_operator/transformers/category'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** CATEGORY Prepare Records Test ***', () => { it('=> transformCategoryRecord: should return an array of type CategoryModel', async () => { diff --git a/app/database/operator/server_data_operator/transformers/category.ts b/app/database/operator/server_data_operator/transformers/category.ts index f2ca14f32b..d1a0fe2fe9 100644 --- a/app/database/operator/server_data_operator/transformers/category.ts +++ b/app/database/operator/server_data_operator/transformers/category.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import type {TransformerArgs} from '@typings/database/database'; import type CategoryModel from '@typings/database/models/servers/category'; diff --git a/app/database/operator/server_data_operator/transformers/channel.test.ts b/app/database/operator/server_data_operator/transformers/channel.test.ts index 71cc8f64d2..73f514d267 100644 --- a/app/database/operator/server_data_operator/transformers/channel.test.ts +++ b/app/database/operator/server_data_operator/transformers/channel.test.ts @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import { transformChannelInfoRecord, transformChannelRecord, @@ -9,7 +10,6 @@ import { transformChannelMembershipRecord, } from '@database/operator/server_data_operator/transformers/channel'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** CHANNEL Prepare Records Test ***', () => { it('=> transformChannelRecord: should return an array of type Channel', async () => { diff --git a/app/database/operator/server_data_operator/transformers/channel.ts b/app/database/operator/server_data_operator/transformers/channel.ts index e27cbf957b..bc79a7ffa7 100644 --- a/app/database/operator/server_data_operator/transformers/channel.ts +++ b/app/database/operator/server_data_operator/transformers/channel.ts @@ -1,10 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; import {extractChannelDisplayName} from '@helpers/database'; -import {OperationType} from '@typings/database/enums'; import type {TransformerArgs} from '@typings/database/database'; import type ChannelModel from '@typings/database/models/servers/channel'; diff --git a/app/database/operator/server_data_operator/transformers/general.test.ts b/app/database/operator/server_data_operator/transformers/general.test.ts index 6cb2beb346..ddf9cc2f64 100644 --- a/app/database/operator/server_data_operator/transformers/general.test.ts +++ b/app/database/operator/server_data_operator/transformers/general.test.ts @@ -1,13 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import { transformCustomEmojiRecord, transformRoleRecord, transformSystemRecord, } from '@database/operator/server_data_operator/transformers/general'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** Role Prepare Records Test ***', () => { it('=> transformRoleRecord: should return an array of type Role', async () => { diff --git a/app/database/operator/server_data_operator/transformers/general.ts b/app/database/operator/server_data_operator/transformers/general.ts index e7e615832f..1cefd4f1d9 100644 --- a/app/database/operator/server_data_operator/transformers/general.ts +++ b/app/database/operator/server_data_operator/transformers/general.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import type {TransformerArgs} from '@typings/database/database'; import type CustomEmojiModel from '@typings/database/models/servers/custom_emoji'; diff --git a/app/database/operator/server_data_operator/transformers/group.test.ts b/app/database/operator/server_data_operator/transformers/group.test.ts index 4d75f850ba..28a84f2695 100644 --- a/app/database/operator/server_data_operator/transformers/group.test.ts +++ b/app/database/operator/server_data_operator/transformers/group.test.ts @@ -1,9 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import {transformGroupRecord} from '@database/operator/server_data_operator/transformers/group'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** GROUP Prepare Records Test ***', () => { it('=> transformGroupRecord: should return an array of type GroupModel', async () => { diff --git a/app/database/operator/server_data_operator/transformers/group.ts b/app/database/operator/server_data_operator/transformers/group.ts index a1c0ed6ddc..0fedf74107 100644 --- a/app/database/operator/server_data_operator/transformers/group.ts +++ b/app/database/operator/server_data_operator/transformers/group.ts @@ -2,9 +2,8 @@ // See LICENSE.txt for license information. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import {generateGroupAssociationId} from '@utils/groups'; import type {TransformerArgs} from '@typings/database/database'; diff --git a/app/database/operator/server_data_operator/transformers/index.ts b/app/database/operator/server_data_operator/transformers/index.ts index e6468b0259..611bfab74d 100644 --- a/app/database/operator/server_data_operator/transformers/index.ts +++ b/app/database/operator/server_data_operator/transformers/index.ts @@ -3,8 +3,9 @@ import Model from '@nozbe/watermelondb/Model'; -import {TransformerArgs} from '@typings/database/database'; -import {OperationType} from '@typings/database/enums'; +import {OperationType} from '@constants/database'; + +import type {TransformerArgs} from '@typings/database/database'; /** * prepareBaseRecord: This is the last step for each operator and depending on the 'action', it will either prepare an diff --git a/app/database/operator/server_data_operator/transformers/post.test.ts b/app/database/operator/server_data_operator/transformers/post.test.ts index ce44cb179f..67eea50924 100644 --- a/app/database/operator/server_data_operator/transformers/post.test.ts +++ b/app/database/operator/server_data_operator/transformers/post.test.ts @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import { transformDraftRecord, transformFileRecord, @@ -9,7 +10,6 @@ import { transformPostsInChannelRecord, } from '@database/operator/server_data_operator/transformers/post'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** POST Prepare Records Test ***', () => { it('=> transformPostRecord: should return an array of type Post', async () => { diff --git a/app/database/operator/server_data_operator/transformers/post.ts b/app/database/operator/server_data_operator/transformers/post.ts index 3574d191e8..64222be626 100644 --- a/app/database/operator/server_data_operator/transformers/post.ts +++ b/app/database/operator/server_data_operator/transformers/post.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import type{TransformerArgs} from '@typings/database/database'; import type DraftModel from '@typings/database/models/servers/draft'; diff --git a/app/database/operator/server_data_operator/transformers/reaction.test.ts b/app/database/operator/server_data_operator/transformers/reaction.test.ts index fc404345bc..1b8675d4e7 100644 --- a/app/database/operator/server_data_operator/transformers/reaction.test.ts +++ b/app/database/operator/server_data_operator/transformers/reaction.test.ts @@ -1,9 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import {transformReactionRecord} from '@database/operator/server_data_operator/transformers/reaction'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** REACTION Prepare Records Test ***', () => { it('=> transformReactionRecord: should return an array of type Reaction', async () => { diff --git a/app/database/operator/server_data_operator/transformers/reaction.ts b/app/database/operator/server_data_operator/transformers/reaction.ts index 78b762c237..eb0ca1e189 100644 --- a/app/database/operator/server_data_operator/transformers/reaction.ts +++ b/app/database/operator/server_data_operator/transformers/reaction.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import type {TransformerArgs} from '@typings/database/database'; import type ReactionModel from '@typings/database/models/servers/reaction'; diff --git a/app/database/operator/server_data_operator/transformers/team.test.ts b/app/database/operator/server_data_operator/transformers/team.test.ts index c536281185..810546fde6 100644 --- a/app/database/operator/server_data_operator/transformers/team.test.ts +++ b/app/database/operator/server_data_operator/transformers/team.test.ts @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import { transformMyTeamRecord, transformTeamChannelHistoryRecord, @@ -9,7 +10,6 @@ import { transformTeamSearchHistoryRecord, } from '@database/operator/server_data_operator/transformers/team'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** TEAM Prepare Records Test ***', () => { it('=> transformMyTeamRecord: should return an array of type MyTeam', async () => { diff --git a/app/database/operator/server_data_operator/transformers/team.ts b/app/database/operator/server_data_operator/transformers/team.ts index a52ee94cb8..f9945558ab 100644 --- a/app/database/operator/server_data_operator/transformers/team.ts +++ b/app/database/operator/server_data_operator/transformers/team.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import type {TransformerArgs} from '@typings/database/database'; import type MyTeamModel from '@typings/database/models/servers/my_team'; diff --git a/app/database/operator/server_data_operator/transformers/thread.ts b/app/database/operator/server_data_operator/transformers/thread.ts index 6fc92cd5d9..d143e79439 100644 --- a/app/database/operator/server_data_operator/transformers/thread.ts +++ b/app/database/operator/server_data_operator/transformers/thread.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import type {TransformerArgs} from '@typings/database/database'; import type ThreadModel from '@typings/database/models/servers/thread'; diff --git a/app/database/operator/server_data_operator/transformers/user.test.ts b/app/database/operator/server_data_operator/transformers/user.test.ts index 4d2d3c30bd..bf4d487349 100644 --- a/app/database/operator/server_data_operator/transformers/user.test.ts +++ b/app/database/operator/server_data_operator/transformers/user.test.ts @@ -1,9 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {OperationType} from '@constants/database'; import {transformPreferenceRecord, transformUserRecord} from '@database/operator/server_data_operator/transformers/user'; import {createTestConnection} from '@database/operator/utils/create_test_connection'; -import {OperationType} from '@typings/database/enums'; describe('*** USER Prepare Records Test ***', () => { it('=> transformPreferenceRecord: should return an array of type Preference', async () => { diff --git a/app/database/operator/server_data_operator/transformers/user.ts b/app/database/operator/server_data_operator/transformers/user.ts index 4f3df663aa..2b84c7ae8d 100644 --- a/app/database/operator/server_data_operator/transformers/user.ts +++ b/app/database/operator/server_data_operator/transformers/user.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {MM_TABLES} from '@constants/database'; +import {MM_TABLES, OperationType} from '@constants/database'; import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index'; -import {OperationType} from '@typings/database/enums'; import type {TransformerArgs} from '@typings/database/database'; import type PreferenceModel from '@typings/database/models/servers/preference'; diff --git a/app/database/operator/utils/create_test_connection.ts b/app/database/operator/utils/create_test_connection.ts index 0025ad0a9a..9cf8831ee6 100644 --- a/app/database/operator/utils/create_test_connection.ts +++ b/app/database/operator/utils/create_test_connection.ts @@ -1,8 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {DatabaseType} from '@constants/database'; import DatabaseManager from '@database/manager'; -import {DatabaseType} from '@typings/database/enums'; export const createTestConnection = async ({databaseName = 'db_name', setActive = false}) => { const serverUrl = 'https://appv2.mattermost.com'; diff --git a/app/helpers/api/team.ts b/app/helpers/api/team.ts index 8471e8290e..e3d35d5965 100644 --- a/app/helpers/api/team.ts +++ b/app/helpers/api/team.ts @@ -2,7 +2,8 @@ // See LICENSE.txt for license information. import {DEFAULT_LOCALE} from '@i18n'; -import TeamModel from '@typings/database/models/servers/team'; + +import type TeamModel from '@typings/database/models/servers/team'; export const selectDefaultTeam = (teams: Array, locale = DEFAULT_LOCALE, userTeamOrderPreference = '', primaryTeam = '') => { let defaultTeam; diff --git a/app/hooks/gallery.ts b/app/hooks/gallery.ts index 03c115985d..74fa683c56 100644 --- a/app/hooks/gallery.ts +++ b/app/hooks/gallery.ts @@ -11,6 +11,7 @@ import { import {useGallery} from '@context/gallery'; +import type {Context, GestureHandlers, OnGestureEvent} from '@typings/screens/gallery'; import type {GestureHandlerGestureEvent} from 'react-native-gesture-handler'; function useRemoteContext(initialValue: T) { diff --git a/app/init/credentials.ts b/app/init/credentials.ts index 6929ce0be3..01231d4688 100644 --- a/app/init/credentials.ts +++ b/app/init/credentials.ts @@ -9,8 +9,6 @@ import * as analytics from '@managers/analytics'; import {logWarning} from '@utils/log'; import {getIOSAppGroupDetails} from '@utils/mattermost_managed'; -import type {ServerCredential} from '@typings/credentials'; - export const getAllServerCredentials = async (): Promise => { const serverCredentials: ServerCredential[] = []; diff --git a/app/init/launch.ts b/app/init/launch.ts index d0016b0a00..c9c38f8411 100644 --- a/app/init/launch.ts +++ b/app/init/launch.ts @@ -6,7 +6,7 @@ import {Alert, Linking, Platform} from 'react-native'; import {Notifications} from 'react-native-notifications'; import {appEntry, pushNotificationEntry, upgradeEntry} from '@actions/remote/entry'; -import {Screens} from '@constants'; +import {Screens, DeepLink, Launch} from '@constants'; import DatabaseManager from '@database/manager'; import {getActiveServerUrl, getServerCredentials, removeServerCredentials} from '@init/credentials'; import {getThemeForCurrentTeam} from '@queries/servers/preference'; @@ -14,11 +14,12 @@ import {getCurrentUserId} from '@queries/servers/system'; import {queryMyTeams} from '@queries/servers/team'; import {goToScreen, resetToHome, resetToSelectServer, resetToTeams} from '@screens/navigation'; import EphemeralStore from '@store/ephemeral_store'; -import {DeepLinkChannel, DeepLinkDM, DeepLinkGM, DeepLinkPermalink, DeepLinkType, DeepLinkWithData, LaunchProps, LaunchType} from '@typings/launch'; import {logInfo} from '@utils/log'; import {convertToNotificationData} from '@utils/notification'; import {parseDeepLink} from '@utils/url'; +import type {DeepLinkChannel, DeepLinkDM, DeepLinkGM, DeepLinkPermalink, DeepLinkWithData, LaunchProps} from '@typings/launch'; + export const initialLaunch = async () => { const deepLinkUrl = await Linking.getInitialURL(); if (deepLinkUrl) { @@ -42,7 +43,7 @@ export const initialLaunch = async () => { return; } - launchApp({launchType: LaunchType.Normal}); + launchApp({launchType: Launch.Normal}); }; const launchAppFromDeepLink = (deepLinkUrl: string) => { @@ -58,13 +59,13 @@ const launchAppFromNotification = async (notification: NotificationWithData) => const launchApp = async (props: LaunchProps, resetNavigation = true) => { let serverUrl: string | undefined; switch (props?.launchType) { - case LaunchType.DeepLink: - if (props.extra?.type !== DeepLinkType.Invalid) { + case Launch.DeepLink: + if (props.extra?.type !== DeepLink.Invalid) { const extra = props.extra as DeepLinkWithData; serverUrl = extra.data?.serverUrl; } break; - case LaunchType.Notification: { + case Launch.Notification: { serverUrl = props.serverUrl; break; } @@ -91,8 +92,8 @@ const launchApp = async (props: LaunchProps, resetNavigation = true) => { let launchType = props.launchType; if (!hasCurrentUser) { // migrating from v1 - if (launchType === LaunchType.Normal) { - launchType = LaunchType.Upgrade; + if (launchType === Launch.Normal) { + launchType = Launch.Upgrade; } const result = await upgradeEntry(serverUrl); @@ -126,11 +127,11 @@ const launchToHome = async (props: LaunchProps) => { let openPushNotification = false; switch (props.launchType) { - case LaunchType.DeepLink: + case Launch.DeepLink: // TODO: // deepLinkEntry({props.serverUrl, props.extra}); break; - case LaunchType.Notification: { + case Launch.Notification: { const extra = props.extra as NotificationWithData; openPushNotification = Boolean(props.serverUrl && !props.launchError && extra.userInteraction && extra.payload?.channel_id && !extra.payload?.userInfo?.local); if (openPushNotification) { @@ -140,7 +141,7 @@ const launchToHome = async (props: LaunchProps) => { } break; } - case LaunchType.Normal: + case Launch.Normal: appEntry(props.serverUrl!); break; } @@ -179,29 +180,29 @@ export const relaunchApp = (props: LaunchProps, resetNavigation = false) => { export const getLaunchPropsFromDeepLink = (deepLinkUrl: string): LaunchProps => { const parsed = parseDeepLink(deepLinkUrl); const launchProps: LaunchProps = { - launchType: LaunchType.DeepLink, + launchType: Launch.DeepLink, }; switch (parsed.type) { - case DeepLinkType.Invalid: + case DeepLink.Invalid: launchProps.launchError = true; break; - case DeepLinkType.Channel: { + case DeepLink.Channel: { const parsedData = parsed.data as DeepLinkChannel; (launchProps.extra as DeepLinkWithData).data = parsedData; break; } - case DeepLinkType.DirectMessage: { + case DeepLink.DirectMessage: { const parsedData = parsed.data as DeepLinkDM; (launchProps.extra as DeepLinkWithData).data = parsedData; break; } - case DeepLinkType.GroupMessage: { + case DeepLink.GroupMessage: { const parsedData = parsed.data as DeepLinkGM; (launchProps.extra as DeepLinkWithData).data = parsedData; break; } - case DeepLinkType.Permalink: { + case DeepLink.Permalink: { const parsedData = parsed.data as DeepLinkPermalink; (launchProps.extra as DeepLinkWithData).data = parsedData; break; @@ -213,7 +214,7 @@ export const getLaunchPropsFromDeepLink = (deepLinkUrl: string): LaunchProps => export const getLaunchPropsFromNotification = async (notification: NotificationWithData): Promise => { const launchProps: LaunchProps = { - launchType: LaunchType.Notification, + launchType: Launch.Notification, }; const {payload} = notification; diff --git a/app/managers/global_event_handler.ts b/app/managers/global_event_handler.ts index 692fa23e6d..029f1b98d0 100644 --- a/app/managers/global_event_handler.ts +++ b/app/managers/global_event_handler.ts @@ -7,7 +7,7 @@ import semver from 'semver'; import {selectAllMyChannelIds} from '@actions/local/channel'; import LocalConfig from '@assets/config.json'; -import {Events, Sso} from '@constants'; +import {Events, Sso, Launch} from '@constants'; import DatabaseManager from '@database/manager'; import {DEFAULT_LOCALE, getTranslations, resetMomentLocale, t} from '@i18n'; import {getServerCredentials, removeServerCredentials} from '@init/credentials'; @@ -18,9 +18,11 @@ import NetworkManager from '@managers/network_manager'; import WebsocketManager from '@managers/websocket_manager'; import {getCurrentUser} from '@queries/servers/user'; import EphemeralStore from '@store/ephemeral_store'; -import {LaunchType} from '@typings/launch'; import {deleteFileCache} from '@utils/file'; +import type {jsAndNativeErrorHandler} from '@typings/global/error_handling'; +import type {LaunchType} from '@typings/launch'; + type LinkingCallbackArg = {url: string}; type LogoutCallbackArg = { @@ -116,10 +118,10 @@ class GlobalEventHandler { if (activeServerUrl === serverUrl) { let displayName = ''; - let launchType: LaunchType = LaunchType.AddServer; + let launchType: LaunchType = Launch.AddServer; if (!Object.keys(DatabaseManager.serverDatabases).length) { EphemeralStore.theme = undefined; - launchType = LaunchType.Normal; + launchType = Launch.Normal; if (activeServerDisplayName) { displayName = activeServerDisplayName; diff --git a/app/managers/network_manager.ts b/app/managers/network_manager.ts index bd19a21a2d..ae38185e79 100644 --- a/app/managers/network_manager.ts +++ b/app/managers/network_manager.ts @@ -20,8 +20,6 @@ import ManagedApp from '@init/managed_app'; import {logError} from '@utils/log'; import {getCSRFFromCookie} from '@utils/security'; -import type {ServerCredential} from '@typings/credentials'; - const CLIENT_CERTIFICATE_IMPORT_ERROR_CODES = [-103, -104, -105, -108]; const CLIENT_CERTIFICATE_MISSING_ERROR_CODE = -200; diff --git a/app/managers/websocket_manager.ts b/app/managers/websocket_manager.ts index 61d1af5cda..e19446eaa5 100644 --- a/app/managers/websocket_manager.ts +++ b/app/managers/websocket_manager.ts @@ -16,8 +16,6 @@ import {getCurrentUserId} from '@queries/servers/system'; import {queryAllUsers} from '@queries/servers/user'; import {logError} from '@utils/log'; -import type {ServerCredential} from '@typings/credentials'; - const WAIT_TO_CLOSE = 15 * 1000; const WAIT_UNTIL_NEXT = 20 * 1000; diff --git a/app/products/calls/components/calls_custom_message/index.ts b/app/products/calls/components/calls_custom_message/index.ts index b40fcd7acd..881c696094 100644 --- a/app/products/calls/components/calls_custom_message/index.ts +++ b/app/products/calls/components/calls_custom_message/index.ts @@ -14,8 +14,8 @@ import {getPreferenceAsBool} from '@helpers/api/preference'; import {observeChannel} from '@queries/servers/channel'; import {queryPreferencesByCategoryAndName} from '@queries/servers/preference'; import {observeCurrentUser, observeTeammateNameDisplay, observeUser} from '@queries/servers/user'; -import {WithDatabaseArgs} from '@typings/database/database'; +import type {WithDatabaseArgs} from '@typings/database/database'; import type PostModel from '@typings/database/models/servers/post'; const enhanced = withObservables(['post'], ({post, database}: { post: PostModel } & WithDatabaseArgs) => { diff --git a/app/products/calls/components/join_call_banner/index.ts b/app/products/calls/components/join_call_banner/index.ts index ea1d60b8f8..5022b10fd9 100644 --- a/app/products/calls/components/join_call_banner/index.ts +++ b/app/products/calls/components/join_call_banner/index.ts @@ -11,7 +11,8 @@ import {observeCallsState, observeCurrentCall} from '@calls/state'; import {idsAreEqual} from '@calls/utils'; import {observeChannel} from '@queries/servers/channel'; import {queryUsersById} from '@queries/servers/user'; -import {WithDatabaseArgs} from '@typings/database/database'; + +import type {WithDatabaseArgs} from '@typings/database/database'; type OwnProps = { serverUrl: string; diff --git a/app/products/calls/screens/call_screen/call_screen.tsx b/app/products/calls/screens/call_screen/call_screen.tsx index ac543bc15d..394a6b55e4 100644 --- a/app/products/calls/screens/call_screen/call_screen.tsx +++ b/app/products/calls/screens/call_screen/call_screen.tsx @@ -33,8 +33,7 @@ import {CallParticipant, CurrentCall, VoiceEventData} from '@calls/types/calls'; import {sortParticipants} from '@calls/utils'; import CompassIcon from '@components/compass_icon'; import SlideUpPanelItem, {ITEM_HEIGHT} from '@components/slide_up_panel_item'; -import {WebsocketEvents} from '@constants'; -import Screens from '@constants/screens'; +import {WebsocketEvents, Screens} from '@constants'; import {useTheme} from '@context/theme'; import DatabaseManager from '@database/manager'; import {bottomSheet, dismissBottomSheet, goToScreen, popTopScreen} from '@screens/navigation'; diff --git a/app/products/calls/utils.ts b/app/products/calls/utils.ts index 9a5e4a5de6..077b2da148 100644 --- a/app/products/calls/utils.ts +++ b/app/products/calls/utils.ts @@ -4,12 +4,11 @@ import {Alert} from 'react-native'; import {CallParticipant} from '@calls/types/calls'; -import {Post} from '@constants'; -import Calls from '@constants/calls'; -import PostModel from '@typings/database/models/servers/post'; +import {Post, Calls} from '@constants'; import {isMinimumServerVersion} from '@utils/helpers'; import {displayUsername} from '@utils/user'; +import type PostModel from '@typings/database/models/servers/post'; import type {IntlShape} from 'react-intl'; export function sortParticipants(teammateNameDisplay: string, participants?: Dictionary, presenterID?: string): CallParticipant[] { diff --git a/app/screens/channel_info/channel_info.tsx b/app/screens/channel_info/channel_info.tsx index 868017e6cc..1e6ee7eeb0 100644 --- a/app/screens/channel_info/channel_info.tsx +++ b/app/screens/channel_info/channel_info.tsx @@ -5,7 +5,7 @@ import React, {useCallback} from 'react'; import {ScrollView, View} from 'react-native'; import {Edge, SafeAreaView} from 'react-native-safe-area-context'; -import ChannelInfoEnableCalls from '@app/products/calls/components/channel_info_enable_calls'; +import ChannelInfoEnableCalls from '@calls/components/channel_info_enable_calls'; import ChannelActions from '@components/channel_actions'; import {useTheme} from '@context/theme'; import useNavButtonPressed from '@hooks/navigation_button_pressed'; diff --git a/app/screens/gallery/document_renderer/document_renderer.tsx b/app/screens/gallery/document_renderer/document_renderer.tsx index 72504e2a45..693be2b002 100644 --- a/app/screens/gallery/document_renderer/document_renderer.tsx +++ b/app/screens/gallery/document_renderer/document_renderer.tsx @@ -17,6 +17,8 @@ import {typography} from '@utils/typography'; import DownloadWithAction from '../footer/download_with_action'; +import type {GalleryAction, GalleryItemType} from '@typings/screens/gallery'; + type Props = { canDownloadFiles: boolean; item: GalleryItemType; diff --git a/app/screens/gallery/footer/copy_public_link/index.tsx b/app/screens/gallery/footer/copy_public_link/index.tsx index f4f1319e9f..3925fcdcff 100644 --- a/app/screens/gallery/footer/copy_public_link/index.tsx +++ b/app/screens/gallery/footer/copy_public_link/index.tsx @@ -13,6 +13,8 @@ import Toast from '@components/toast'; import {GALLERY_FOOTER_HEIGHT} from '@constants/gallery'; import {useServerUrl} from '@context/server'; +import type {GalleryAction, GalleryItemType} from '@typings/screens/gallery'; + type Props = { item: GalleryItemType; setAction: (action: GalleryAction) => void; diff --git a/app/screens/gallery/footer/download_with_action/index.tsx b/app/screens/gallery/footer/download_with_action/index.tsx index 59e34af0b0..cba4d9478f 100644 --- a/app/screens/gallery/footer/download_with_action/index.tsx +++ b/app/screens/gallery/footer/download_with_action/index.tsx @@ -25,6 +25,7 @@ import {galleryItemToFileInfo} from '@utils/gallery'; import {typography} from '@utils/typography'; import type {ClientResponse, ProgressPromise} from '@mattermost/react-native-network-client'; +import type {GalleryAction, GalleryItemType} from '@typings/screens/gallery'; type Props = { action: GalleryAction; diff --git a/app/screens/gallery/footer/footer.tsx b/app/screens/gallery/footer/footer.tsx index a9c1c74d1e..1d1f753b0c 100644 --- a/app/screens/gallery/footer/footer.tsx +++ b/app/screens/gallery/footer/footer.tsx @@ -20,6 +20,7 @@ import DownloadWithAction from './download_with_action'; import type PostModel from '@typings/database/models/servers/post'; import type UserModel from '@typings/database/models/servers/user'; +import type {GalleryAction, GalleryItemType} from '@typings/screens/gallery'; type Props = { author?: UserModel; diff --git a/app/screens/gallery/footer/index.ts b/app/screens/gallery/footer/index.ts index 4afd4b6545..a030a99059 100644 --- a/app/screens/gallery/footer/index.ts +++ b/app/screens/gallery/footer/index.ts @@ -16,6 +16,7 @@ import Footer from './footer'; import type {WithDatabaseArgs} from '@typings/database/database'; import type ChannelModel from '@typings/database/models/servers/channel'; +import type {GalleryItemType} from '@typings/screens/gallery'; type FooterProps = WithDatabaseArgs & { item: GalleryItemType; diff --git a/app/screens/gallery/gallery.tsx b/app/screens/gallery/gallery.tsx index 7919bbe1ba..3f294f44f9 100644 --- a/app/screens/gallery/gallery.tsx +++ b/app/screens/gallery/gallery.tsx @@ -16,6 +16,8 @@ import Backdrop, {BackdropProps} from './lightbox_swipeout/backdrop'; import VideoRenderer from './video_renderer'; import GalleryViewer from './viewer'; +import type {GalleryItemType} from '@typings/screens/gallery'; + // @ts-expect-error FastImage does work with Animated.createAnimatedComponent const AnimatedImage = Animated.createAnimatedComponent(FastImage); diff --git a/app/screens/gallery/index.tsx b/app/screens/gallery/index.tsx index 923ef48d9a..de8eb82fa9 100644 --- a/app/screens/gallery/index.tsx +++ b/app/screens/gallery/index.tsx @@ -15,6 +15,8 @@ import Footer from './footer'; import Gallery, {GalleryRef} from './gallery'; import Header from './header'; +import type {GalleryItemType} from '@typings/screens/gallery'; + type Props = { galleryIdentifier: string; hideActions: boolean; diff --git a/app/screens/gallery/lightbox_swipeout/index.tsx b/app/screens/gallery/lightbox_swipeout/index.tsx index 03e211eb8a..a2acb20c89 100644 --- a/app/screens/gallery/lightbox_swipeout/index.tsx +++ b/app/screens/gallery/lightbox_swipeout/index.tsx @@ -18,6 +18,7 @@ import {freezeOtherScreens} from '@utils/gallery'; import {calculateDimensions} from '@utils/images'; import type {BackdropProps} from './backdrop'; +import type {GalleryItemType, GalleryManagerSharedValues} from '@typings/screens/gallery'; interface Size { height: number; diff --git a/app/screens/gallery/pager/index.tsx b/app/screens/gallery/pager/index.tsx index a637fa9517..276741663d 100644 --- a/app/screens/gallery/pager/index.tsx +++ b/app/screens/gallery/pager/index.tsx @@ -11,6 +11,8 @@ import {clampVelocity, friction, getShouldRender, workletNoop, workletNoopTrue} import Page, {PageRefs, RenderPageProps} from './page'; +import type {GalleryItemType} from '@typings/screens/gallery'; + export interface PagerReusableProps { gutterWidth?: number; initialDiffValue?: number; diff --git a/app/screens/gallery/pager/page.tsx b/app/screens/gallery/pager/page.tsx index cd4938a16e..37bf2875ab 100644 --- a/app/screens/gallery/pager/page.tsx +++ b/app/screens/gallery/pager/page.tsx @@ -10,6 +10,8 @@ import {typedMemo} from '@utils/gallery'; import Gutter from './gutter'; +import type {GalleryItemType} from '@typings/screens/gallery'; + export type PageRefs = [ React.Ref, React.Ref, diff --git a/app/screens/gallery/video_renderer/index.tsx b/app/screens/gallery/video_renderer/index.tsx index ab9fa44b1d..0ac0ac584a 100644 --- a/app/screens/gallery/video_renderer/index.tsx +++ b/app/screens/gallery/video_renderer/index.tsx @@ -18,6 +18,7 @@ import {changeOpacity} from '@utils/theme'; import DownloadWithAction from '../footer/download_with_action'; import type {ImageRendererProps} from '../image_renderer'; +import type {GalleryAction} from '@typings/screens/gallery'; interface VideoRendererProps extends ImageRendererProps { index: number; diff --git a/app/screens/gallery/viewer/index.tsx b/app/screens/gallery/viewer/index.tsx index fed7c7eb19..08002bec67 100644 --- a/app/screens/gallery/viewer/index.tsx +++ b/app/screens/gallery/viewer/index.tsx @@ -9,6 +9,8 @@ import {InteractionType} from '../image_renderer/transformer'; import Pager from '../pager'; import {RenderPageProps} from '../pager/page'; +import type {GalleryItemType} from '@typings/screens/gallery'; + export interface GalleryViewerProps extends Handlers { gutterWidth?: number; height: number; diff --git a/app/screens/home/search/results/file_options/file_options.tsx b/app/screens/home/search/results/file_options/file_options.tsx index b377a597f0..a16f8f198e 100644 --- a/app/screens/home/search/results/file_options/file_options.tsx +++ b/app/screens/home/search/results/file_options/file_options.tsx @@ -12,6 +12,8 @@ import DownloadWithAction from '@screens/gallery/footer/download_with_action'; import Header from './header'; +import type {GalleryAction, GalleryItemType} from '@typings/screens/gallery'; + const styles = StyleSheet.create({ toast: { marginTop: 100, diff --git a/app/screens/home/search/results/results.tsx b/app/screens/home/search/results/results.tsx index 37d1d8d6cc..8eaf6f30ce 100644 --- a/app/screens/home/search/results/results.tsx +++ b/app/screens/home/search/results/results.tsx @@ -6,9 +6,9 @@ import {StyleSheet, FlatList, ListRenderItemInfo, StyleProp, View, ViewStyle} fr import Animated from 'react-native-reanimated'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; -import {ITEM_HEIGHT} from '@app/components/option_item'; import File from '@components/files/file'; import NoResultsWithTerm from '@components/no_results_with_term'; +import {ITEM_HEIGHT} from '@components/option_item'; import DateSeparator from '@components/post_list/date_separator'; import PostWithChannelInfo from '@components/post_with_channel_info'; import {Screens} from '@constants'; diff --git a/app/screens/login/types.d.ts b/app/screens/login/types.d.ts deleted file mode 100644 index 66d254ba36..0000000000 --- a/app/screens/login/types.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -type LoginOptionWithConfigProps = { - ssoType?: string; - config: ClientConfig; - onPress: (type: string|GestureResponderEvent) => void | (() => void); - theme: Theme; -} - -type LoginOptionWithConfigAndLicenseProps = LoginOptionWithConfigProps & { - license?: ClientLicense; -}; diff --git a/app/screens/navigation.ts b/app/screens/navigation.ts index d89a2869ad..8733cd86f7 100644 --- a/app/screens/navigation.ts +++ b/app/screens/navigation.ts @@ -10,19 +10,18 @@ import tinyColor from 'tinycolor2'; import CompassIcon from '@components/compass_icon'; import {ITEM_HEIGHT} from '@components/team_sidebar/add_team/team_list_item/team_list_item'; -import {Device, Events, Screens} from '@constants'; -import NavigationConstants from '@constants/navigation'; +import {Device, Events, Screens, Navigation as NavigationConstants, Launch} from '@constants'; import {NOT_READY} from '@constants/screens'; import {getDefaultThemeByAppearance} from '@context/theme'; import {TITLE_HEIGHT} from '@screens/bottom_sheet/content'; import EphemeralStore from '@store/ephemeral_store'; import NavigationStore from '@store/navigation_store'; -import {LaunchProps, LaunchType} from '@typings/launch'; import {bottomSheetSnapPoint} from '@utils/helpers'; import {appearanceControlledScreens, mergeNavigationOptions} from '@utils/navigation'; import {changeOpacity, setNavigatorStyles} from '@utils/theme'; import type TeamModel from '@typings/database/models/servers/team'; +import type {LaunchProps} from '@typings/launch'; import type {NavButtons} from '@typings/screens/navigation'; const {MattermostManaged} = NativeModules; @@ -187,12 +186,12 @@ function isScreenRegistered(screen: string) { return true; } -export function resetToHome(passProps: LaunchProps = {launchType: LaunchType.Normal}) { +export function resetToHome(passProps: LaunchProps = {launchType: Launch.Normal}) { const theme = getThemeFromState(); const isDark = tinyColor(theme.sidebarBg).isDark(); StatusBar.setBarStyle(isDark ? 'light-content' : 'dark-content'); - if (passProps.launchType === LaunchType.AddServer) { + if (passProps.launchType === Launch.AddServer) { dismissModal({componentId: Screens.SERVER}); dismissModal({componentId: Screens.LOGIN}); dismissModal({componentId: Screens.SSO}); diff --git a/app/screens/permalink/index.ts b/app/screens/permalink/index.ts index 050fabc50c..1a890bd215 100644 --- a/app/screens/permalink/index.ts +++ b/app/screens/permalink/index.ts @@ -10,11 +10,11 @@ import {observePost} from '@queries/servers/post'; import {observeCurrentTeamId, observeCurrentUserId} from '@queries/servers/system'; import {queryMyTeamsByIds, queryTeamByName} from '@queries/servers/team'; import {observeIsCRTEnabled} from '@queries/servers/thread'; -import PostModel from '@typings/database/models/servers/post'; import Permalink from './permalink'; import type {WithDatabaseArgs} from '@typings/database/database'; +import type PostModel from '@typings/database/models/servers/post'; type OwnProps = { postId: PostModel['id']; diff --git a/app/screens/server/index.tsx b/app/screens/server/index.tsx index b8b0cb305d..26a719542d 100644 --- a/app/screens/server/index.tsx +++ b/app/screens/server/index.tsx @@ -15,7 +15,7 @@ import {fetchConfigAndLicense} from '@actions/remote/systems'; import LocalConfig from '@assets/config.json'; import ClientError from '@client/rest/error'; import AppVersion from '@components/app_version'; -import {Screens} from '@constants'; +import {Screens, Launch} from '@constants'; import {PUSH_PROXY_RESPONSE_NOT_AVAILABLE, PUSH_PROXY_RESPONSE_UNKNOWN, PUSH_PROXY_STATUS_NOT_AVAILABLE, PUSH_PROXY_STATUS_UNKNOWN, PUSH_PROXY_STATUS_VERIFIED} from '@constants/push_proxy'; import DatabaseManager from '@database/manager'; import {t} from '@i18n'; @@ -24,7 +24,6 @@ import {queryServerByDisplayName, queryServerByIdentifier} from '@queries/app/se import Background from '@screens/background'; import {dismissModal, goToScreen, loginAnimationOptions} from '@screens/navigation'; import EphemeralStore from '@store/ephemeral_store'; -import {DeepLinkWithData, LaunchProps, LaunchType} from '@typings/launch'; import {getErrorMessage} from '@utils/client_error'; import {alertPushProxyError, alertPushProxyUnknown} from '@utils/push_proxy'; import {loginOptions} from '@utils/server'; @@ -34,6 +33,8 @@ import {getServerUrlAfterRedirect, isValidUrl, sanitizeUrl} from '@utils/url'; import ServerForm from './form'; import ServerHeader from './header'; +import type {DeepLinkWithData, LaunchProps} from '@typings/launch'; + interface ServerProps extends LaunchProps { closeButtonId?: string; componentId: string; @@ -78,7 +79,7 @@ const Server = ({ let serverUrl: string | undefined = defaultServerUrl || managedConfig?.serverUrl || LocalConfig.DefaultServerUrl; let autoconnect = managedConfig?.allowOtherServers === 'false' || LocalConfig.AutoSelectServerUrl; - if (launchType === LaunchType.DeepLink) { + if (launchType === Launch.DeepLink) { const deepLinkServerUrl = (extra as DeepLinkWithData).data?.serverUrl; if (managedConfig) { autoconnect = (managedConfig.allowOtherServers === 'false' && managedConfig.serverUrl === deepLinkServerUrl); @@ -92,7 +93,7 @@ const Server = ({ autoconnect = true; serverUrl = deepLinkServerUrl; } - } else if (launchType === LaunchType.AddServer) { + } else if (launchType === Launch.AddServer) { serverName = defaultDisplayName; serverUrl = defaultServerUrl; } @@ -335,11 +336,11 @@ const Server = ({ style={styles.flex} > { 'worklet'; diff --git a/app/utils/server/index.ts b/app/utils/server/index.ts index 022552d9f5..b3a53b2095 100644 --- a/app/utils/server/index.ts +++ b/app/utils/server/index.ts @@ -5,9 +5,8 @@ import {IntlShape} from 'react-intl'; import {Alert, AlertButton} from 'react-native'; import CompassIcon from '@components/compass_icon'; -import {Screens, Sso, SupportedServer} from '@constants'; +import {Screens, Sso, SupportedServer, Launch} from '@constants'; import {dismissBottomSheet, showModal} from '@screens/navigation'; -import {LaunchType} from '@typings/launch'; import {getErrorMessage} from '@utils/client_error'; import {changeOpacity} from '@utils/theme'; import {tryOpenURL} from '@utils/url'; @@ -41,7 +40,7 @@ export async function addNewServer(theme: Theme, serverUrl?: string, displayName const props = { closeButtonId, displayName, - launchType: LaunchType.AddServer, + launchType: Launch.AddServer, serverUrl, theme, }; @@ -85,7 +84,7 @@ export async function loginToServer(theme: Theme, serverUrl: string, displayName closeButtonId, config, hasLoginForm, - launchType: LaunchType.AddServer, + launchType: Launch.AddServer, license, serverDisplayName: displayName, serverUrl, diff --git a/app/utils/url/index.ts b/app/utils/url/index.ts index 36b2a53ca8..86b6ab0a0e 100644 --- a/app/utils/url/index.ts +++ b/app/utils/url/index.ts @@ -5,13 +5,14 @@ import GenericClient from '@mattermost/react-native-network-client'; import {Linking} from 'react-native'; import urlParse from 'url-parse'; -import {Files} from '@constants'; -import {DeepLinkType, DeepLinkWithData} from '@typings/launch'; +import {Files, DeepLink} from '@constants'; import {emptyFunction} from '@utils/general'; import {escapeRegex} from '@utils/markdown'; import {latinise} from './latinise'; +import type {DeepLinkWithData} from '@typings/launch'; + const ytRegex = /(?:http|https):\/\/(?:www\.|m\.)?(?:(?:youtube\.com\/(?:(?:v\/)|(?:(?:watch|embed\/watch)(?:\/|.*v=))|(?:embed\/)|(?:user\/[^/]+\/u\/[0-9]\/)))|(?:youtu\.be\/))([^#&?]*)/; export function isValidUrl(url = '') { @@ -141,30 +142,30 @@ export function parseDeepLink(deepLinkUrl: string): DeepLinkWithData { let match = new RegExp('(.*)\\/([^\\/]+)\\/channels\\/(\\S+)').exec(url); if (match) { - return {type: DeepLinkType.Channel, data: {serverUrl: match[1], teamName: match[2], channelName: match[3]}}; + return {type: DeepLink.Channel, data: {serverUrl: match[1], teamName: match[2], channelName: match[3]}}; } match = new RegExp('(.*)\\/([^\\/]+)\\/pl\\/(\\w+)').exec(url); if (match) { - return {type: DeepLinkType.Permalink, data: {serverUrl: match[1], teamName: match[2], postId: match[3]}}; + return {type: DeepLink.Permalink, data: {serverUrl: match[1], teamName: match[2], postId: match[3]}}; } match = new RegExp('(.*)\\/([^\\/]+)\\/messages\\/@(\\S+)').exec(url); if (match) { - return {type: DeepLinkType.DirectMessage, data: {serverUrl: match[1], teamName: match[2], userName: match[3]}}; + return {type: DeepLink.DirectMessage, data: {serverUrl: match[1], teamName: match[2], userName: match[3]}}; } match = new RegExp('(.*)\\/([^\\/]+)\\/messages\\/(\\S+)').exec(url); if (match) { - return {type: DeepLinkType.GroupMessage, data: {serverUrl: match[1], teamName: match[2], channelId: match[3]}}; + return {type: DeepLink.GroupMessage, data: {serverUrl: match[1], teamName: match[2], channelId: match[3]}}; } match = new RegExp('(.*)\\/plugins\\/([^\\/]+)\\/(\\S+)').exec(url); if (match) { - return {type: DeepLinkType.Plugin, data: {serverUrl: match[1], id: match[2], teamName: ''}}; + return {type: DeepLink.Plugin, data: {serverUrl: match[1], id: match[2], teamName: ''}}; } - return {type: DeepLinkType.Invalid}; + return {type: DeepLink.Invalid}; } export function matchDeepLink(url?: string, serverURL?: string, siteURL?: string) { @@ -185,7 +186,7 @@ export function matchDeepLink(url?: string, serverURL?: string, siteURL?: string } const parsedDeepLink = parseDeepLink(urlToMatch); - if (parsedDeepLink.type !== DeepLinkType.Invalid) { + if (parsedDeepLink.type !== DeepLink.Invalid) { return parsedDeepLink; } diff --git a/app/utils/url/test.ts b/app/utils/url/test.ts index 9efa367cbe..8c2500eaa7 100644 --- a/app/utils/url/test.ts +++ b/app/utils/url/test.ts @@ -3,7 +3,7 @@ import {Linking} from 'react-native'; -import {DeepLinkType} from '@typings/launch'; +import DeepLinkType from '@constants/deep_linking'; import * as UrlUtils from '@utils/url'; /* eslint-disable max-nested-callbacks */ diff --git a/types/api/posts.d.ts b/types/api/posts.d.ts index 0163bb4862..c36824e4f5 100644 --- a/types/api/posts.d.ts +++ b/types/api/posts.d.ts @@ -55,7 +55,7 @@ type Post = { original_id: string; message: string; type: PostType; - participants?: null | UserProfile[]; + participants?: null | UserProfile[]|string[]; props: Record; hashtags: string; pending_post_id: string; @@ -66,7 +66,6 @@ type Post = { user_activity_posts?: Post[]; state?: 'DELETED'; prev_post_id?: string; - participants: null|string[]; }; type PostProps = { diff --git a/types/api/threads.d.ts b/types/api/threads.d.ts index 9cb379b6ae..886c38facf 100644 --- a/types/api/threads.d.ts +++ b/types/api/threads.d.ts @@ -23,7 +23,7 @@ type ThreadWithViewedAt = Thread & { }; type ThreadParticipant = { - id: $ID; + id: $ID; thread_id: $ID; }; diff --git a/types/components/post_draft_quick_action.d.ts b/types/components/post_draft_quick_action.ts similarity index 85% rename from types/components/post_draft_quick_action.d.ts rename to types/components/post_draft_quick_action.ts index 310bd5b0d9..d2fa43a78e 100644 --- a/types/components/post_draft_quick_action.d.ts +++ b/types/components/post_draft_quick_action.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Asset} from 'react-native-image-picker'; +import type {Asset} from 'react-native-image-picker'; export interface QuickActionAttachmentProps { disabled: boolean; diff --git a/types/components/post_list.d.ts b/types/components/post_list.ts similarity index 86% rename from types/components/post_list.d.ts rename to types/components/post_list.ts index bbc48ea1cb..6cbb9639ca 100644 --- a/types/components/post_list.d.ts +++ b/types/components/post_list.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {ViewToken} from 'react-native'; +import type {ViewToken} from 'react-native'; export type ViewableItemsChanged = { viewableItems: ViewToken[]; diff --git a/types/credentials/index.d.ts b/types/credentials/index.d.ts index d64a2c0134..e81dd6d3f6 100644 --- a/types/credentials/index.d.ts +++ b/types/credentials/index.d.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -export type ServerCredential = { +type ServerCredential = { serverUrl: string; userId: string; token: string; diff --git a/types/database/database.d.ts b/types/database/database.ts similarity index 93% rename from types/database/database.d.ts rename to types/database/database.ts index 39f120dcb1..b2ea93aeac 100644 --- a/types/database/database.d.ts +++ b/types/database/database.ts @@ -3,22 +3,20 @@ /* eslint-disable max-lines */ -import {Database} from '@nozbe/watermelondb'; -import Model from '@nozbe/watermelondb/Model'; -import {Clause} from '@nozbe/watermelondb/QueryDescription'; -import {Class} from '@nozbe/watermelondb/utils/common'; - -import {DatabaseType} from './enums'; - +import type {DatabaseType} from '@constants/database'; import type AppDataOperator from '@database/operator/app_data_operator'; import type ServerDataOperator from '@database/operator/server_data_operator'; +import type {Database} from '@nozbe/watermelondb'; +import type Model from '@nozbe/watermelondb/Model'; +import type {Clause} from '@nozbe/watermelondb/QueryDescription'; +import type {Class} from '@nozbe/watermelondb/utils/common'; import type System from '@typings/database/models/servers/system'; export type WithDatabaseArgs = { database: Database } export type CreateServerDatabaseConfig = { dbName: string; - dbType?: DatabaseType.DEFAULT | DatabaseType.SERVER; + dbType?: DatabaseType; displayName?: string; serverUrl?: string; identifier?: string; @@ -58,7 +56,7 @@ export type OperationArgs = { createRaws?: RecordPair[]; updateRaws?: RecordPair[]; deleteRaws?: Model[]; - transformer: (TransformerArgs) => Promise; + transformer: (args: TransformerArgs) => Promise; }; export type Models = Array>; @@ -155,7 +153,7 @@ export type ProcessRecordsArgs = { export type HandleRecordsArgs = { buildKeyRecordBy?: (obj: Record) => string; fieldName: string; - transformer: (TransformerArgs) => Promise; + transformer: (args: TransformerArgs) => Promise; createOrUpdateRawValues: RawValue[]; deleteRawValues?: RawValue[]; tableName: string; diff --git a/types/database/enums.ts b/types/database/enums.ts deleted file mode 100644 index d0889b2d4a..0000000000 --- a/types/database/enums.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -export enum OperationType { - CREATE = 'CREATE', - UPDATE = 'UPDATE', - DELETE = 'DELETE', -} - -// The only two types of databases in the app -export enum DatabaseType { - DEFAULT, - SERVER, -} diff --git a/types/database/models/app/global.d.ts b/types/database/models/app/global.ts similarity index 81% rename from types/database/models/app/global.d.ts rename to types/database/models/app/global.ts index 19b63d3b9a..b8cbd90b6d 100644 --- a/types/database/models/app/global.d.ts +++ b/types/database/models/app/global.ts @@ -1,16 +1,18 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Model} from '@nozbe/watermelondb'; +import type {Model} from '@nozbe/watermelondb'; /** * The Global model will act as a dictionary of name-value pairs. The value field can be a JSON object or any other * data type. It will hold information that applies to the whole app ( e.g. sidebar settings for tablets) */ -export default class GlobalModel extends Model { +declare class GlobalModel extends Model { /** table (name) : global */ static table: string; /** value : The value part of the key-value combination and whose key will be the id column */ value: any; } + +export default GlobalModel; diff --git a/types/database/models/app/info.d.ts b/types/database/models/app/info.ts similarity index 82% rename from types/database/models/app/info.d.ts rename to types/database/models/app/info.ts index 261ca9a1ae..9d73c04605 100644 --- a/types/database/models/app/info.d.ts +++ b/types/database/models/app/info.ts @@ -1,13 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Model} from '@nozbe/watermelondb'; +import type {Model} from '@nozbe/watermelondb'; /** * The App model will hold information - such as the version number, build number and creation date - * for the Mattermost mobile app. */ -export default class InfoModel extends Model { +declare class InfoModel extends Model { /** table (name) : app */ static table: string; @@ -20,3 +20,5 @@ export default class InfoModel extends Model { /** version_number : Version number for the app */ versionNumber: string; } + +export default InfoModel; diff --git a/types/database/models/app/servers.d.ts b/types/database/models/app/servers.ts similarity index 81% rename from types/database/models/app/servers.d.ts rename to types/database/models/app/servers.ts index dfc066baa3..ef0bfe87af 100644 --- a/types/database/models/app/servers.d.ts +++ b/types/database/models/app/servers.ts @@ -1,13 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Model} from '@nozbe/watermelondb'; +import type {Model} from '@nozbe/watermelondb'; /** * The Server model will help us to identify the various servers a user will log in; in the context of * multi-server support system. The db_path field will hold the App-Groups file-path */ -export default class ServersModel extends Model { +declare class ServersModel extends Model { /** table (name) : servers */ static table: string; @@ -21,8 +21,10 @@ export default class ServersModel extends Model { url: string; /** last_active_at: The last time this server was active */ - lastActiveAt!: number; + lastActiveAt: number; /** diagnostic_id: Determines the installation identifier of a server */ - identifier!: string; + identifier: string; } + +export default ServersModel; diff --git a/types/database/models/servers/category.d.ts b/types/database/models/servers/category.ts similarity index 89% rename from types/database/models/servers/category.d.ts rename to types/database/models/servers/category.ts index f9fecf66c4..fef270ae83 100644 --- a/types/database/models/servers/category.d.ts +++ b/types/database/models/servers/category.ts @@ -1,20 +1,20 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Query, Relation} from '@nozbe/watermelondb'; import {lazy} from '@nozbe/watermelondb/decorators'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; -import {Observable} from 'rxjs'; import type CategoryChannelModel from './category_channel'; import type ChannelModel from './channel'; import type MyChannelModel from './my_channel'; import type TeamModel from './team'; +import type {Query, Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; +import type {Observable} from 'rxjs'; /** * A Category groups together channels for a user in a team. */ -export default class CategoryModel extends Model { +declare class CategoryModel extends Model { /** table (name) : Category */ static table: string; @@ -63,3 +63,5 @@ export default class CategoryModel extends Model { /** toCategoryWithChannels returns a map of the Category with an array of ordered channel ids */ toCategoryWithChannels(): Promise; } + +export default CategoryModel; diff --git a/types/database/models/servers/category_channel.d.ts b/types/database/models/servers/category_channel.ts similarity index 84% rename from types/database/models/servers/category_channel.d.ts rename to types/database/models/servers/category_channel.ts index 4d9ff8f663..6b1afcdbe3 100644 --- a/types/database/models/servers/category_channel.d.ts +++ b/types/database/models/servers/category_channel.ts @@ -1,18 +1,17 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type CategoryModel from './category'; import type ChannelModel from './channel'; import type MyChannelModel from './my_channel'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The CategoryChannel model represents the 'association table' where many categories have channels and many channels are in * categories (relationship type N:N) */ -export default class CategoryChannelModel extends Model { +declare class CategoryChannelModel extends Model { /** table (name) : CategoryChannel */ static table: string; @@ -37,3 +36,5 @@ export default class CategoryChannelModel extends Model { /** myChannel : The related myChannel */ myChannel: Relation; } + +export default CategoryChannelModel; diff --git a/types/database/models/servers/channel.d.ts b/types/database/models/servers/channel.ts similarity index 93% rename from types/database/models/servers/channel.d.ts rename to types/database/models/servers/channel.ts index bb252b1ba1..039a018e67 100644 --- a/types/database/models/servers/channel.d.ts +++ b/types/database/models/servers/channel.ts @@ -1,9 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Query, Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type CategoryChannelModel from './category_channel'; import type ChannelInfoModel from './channel_info'; import type ChannelMembershipModel from './channel_membership'; @@ -13,11 +10,13 @@ import type PostModel from './post'; import type PostsInChannelModel from './posts_in_channel'; import type TeamModel from './team'; import type UserModel from './user'; +import type {Query, Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Channel model represents a channel in the Mattermost app. */ -export default class ChannelModel extends Model { +declare class ChannelModel extends Model { /** table (name) : Channel */ static table: string; @@ -34,7 +33,7 @@ export default class ChannelModel extends Model { deleteAt: number; /** update_at : The timestamp to when this channel was last updated on the server */ - updateAt!: number; + updateAt: number; /** display_name : The channel display name (e.g. Town Square ) */ displayName: string; @@ -83,3 +82,5 @@ export default class ChannelModel extends Model { toApi(): Channel; } + +export default ChannelModel; diff --git a/types/database/models/servers/channel_info.d.ts b/types/database/models/servers/channel_info.ts similarity index 84% rename from types/database/models/servers/channel_info.d.ts rename to types/database/models/servers/channel_info.ts index a679cccc39..79d522ef30 100644 --- a/types/database/models/servers/channel_info.d.ts +++ b/types/database/models/servers/channel_info.ts @@ -1,17 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model from '@nozbe/watermelondb/Model'; - import type ChannelModel from './channel'; +import type {Relation} from '@nozbe/watermelondb'; +import type Model from '@nozbe/watermelondb/Model'; /** * ChannelInfo is an extension of the information contained in the Channel table. * In a Separation of Concerns approach, ChannelInfo will provide additional information about a channel but on a more * specific level. */ -export default class ChannelInfoModel extends Model { +declare class ChannelInfoModel extends Model { /** table (name) : ChannelInfo */ static table: string; @@ -33,3 +32,5 @@ export default class ChannelInfoModel extends Model { /** channel : The lazy query property to the record from the CHANNEL table */ channel: Relation; } + +export default ChannelInfoModel; diff --git a/types/database/models/servers/channel_membership.d.ts b/types/database/models/servers/channel_membership.ts similarity index 86% rename from types/database/models/servers/channel_membership.d.ts rename to types/database/models/servers/channel_membership.ts index e460a7790f..c5d368f412 100644 --- a/types/database/models/servers/channel_membership.d.ts +++ b/types/database/models/servers/channel_membership.ts @@ -1,17 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Query, Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type ChannelModel from './channel'; import type UserModel from './user'; +import type {Query, Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The ChannelMembership model represents the 'association table' where many channels have users and many users are on * channels ( N:N relationship between model Users and model Channel) */ -export default class ChannelMembershipModel extends Model { +declare class ChannelMembershipModel extends Model { /** table (name) : ChannelMembership */ static table: string; @@ -43,3 +42,5 @@ export default class ChannelMembershipModel extends Model { */ getAllUsersInChannel: Query; } + +export default ChannelMembershipModel; diff --git a/types/database/models/servers/custom_emoji.d.ts b/types/database/models/servers/custom_emoji.ts similarity index 71% rename from types/database/models/servers/custom_emoji.d.ts rename to types/database/models/servers/custom_emoji.ts index f67d51759c..787acc644c 100644 --- a/types/database/models/servers/custom_emoji.d.ts +++ b/types/database/models/servers/custom_emoji.ts @@ -1,13 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Model} from '@nozbe/watermelondb'; +import type Model from '@nozbe/watermelondb/Model'; /** The CustomEmoji model describes all the custom emojis used in the Mattermost app */ -export default class CustomEmojiModel extends Model { +declare class CustomEmojiModel extends Model { /** table (name) : CustomEmoji */ static table: string; /** name : The custom emoji's name*/ name: string; } + +export default CustomEmojiModel; diff --git a/types/database/models/servers/draft.d.ts b/types/database/models/servers/draft.ts similarity index 83% rename from types/database/models/servers/draft.d.ts rename to types/database/models/servers/draft.ts index 8a81a44610..91768fd12a 100644 --- a/types/database/models/servers/draft.d.ts +++ b/types/database/models/servers/draft.ts @@ -1,12 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import Model, {Associations} from '@nozbe/watermelondb/Model'; +import type {Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Draft model represents the draft state of messages in Direct/Group messages and in channels */ -export default class DraftModel extends Model { +declare class DraftModel extends Model { /** table (name) : Draft */ static table: string; @@ -25,3 +26,5 @@ export default class DraftModel extends Model { /** files : The files field will hold an array of files object that have not yet been uploaded and persisted within the FILE table */ files: FileInfo[]; } + +export default DraftModel; diff --git a/types/database/models/servers/file.d.ts b/types/database/models/servers/file.ts similarity index 87% rename from types/database/models/servers/file.d.ts rename to types/database/models/servers/file.ts index 82d532a443..1e913605c8 100644 --- a/types/database/models/servers/file.d.ts +++ b/types/database/models/servers/file.ts @@ -1,15 +1,14 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type PostModel from './post'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The File model works in pair with the Post model. It hosts information about the files shared in a Post */ -export default class FileModel extends Model { +declare class FileModel extends Model { /** table (name) : File */ static table: string; @@ -48,3 +47,5 @@ export default class FileModel extends Model { toFileInfo: (authorId: string) => FileInfo; } + +export default FileModel; diff --git a/types/database/models/servers/group.d.ts b/types/database/models/servers/group.ts similarity index 89% rename from types/database/models/servers/group.d.ts rename to types/database/models/servers/group.ts index fb9dc48448..2bb332e079 100644 --- a/types/database/models/servers/group.d.ts +++ b/types/database/models/servers/group.ts @@ -1,18 +1,18 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Query} from '@nozbe/watermelondb'; import {lazy} from '@nozbe/watermelondb/decorators'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; import type ChannelModel from './channel'; import type TeamModel from './team'; import type UserModel from './user'; +import type {Query, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * A Group is a collection of users, associated to teams and/or channels */ -export default class GroupModel extends Model { +declare class GroupModel extends Model { /** table (name) : Group */ static table: string; @@ -55,3 +55,5 @@ export default class GroupModel extends Model { /** members : All the members (users) of this group */ @lazy members: Query; } + +export default GroupModel; diff --git a/types/database/models/servers/group_channel.d.ts b/types/database/models/servers/group_channel.ts similarity index 84% rename from types/database/models/servers/group_channel.d.ts rename to types/database/models/servers/group_channel.ts index 15d957d466..88cbf0bf5c 100644 --- a/types/database/models/servers/group_channel.d.ts +++ b/types/database/models/servers/group_channel.ts @@ -1,17 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type ChannelModel from './channel'; import type GroupModel from './group'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The GroupChannel model represents the 'association table' where many groups have channels and many channels are in * groups (relationship type N:N) */ -export default class GroupChannelModel extends Model { +declare class GroupChannelModel extends Model { /** table (name) : GroupChannel */ static table: string; @@ -39,3 +38,5 @@ export default class GroupChannelModel extends Model { /** channel : The related channel */ channel: Relation; } + +export default GroupChannelModel; diff --git a/types/database/models/servers/group_membership.d.ts b/types/database/models/servers/group_membership.ts similarity index 84% rename from types/database/models/servers/group_membership.d.ts rename to types/database/models/servers/group_membership.ts index cd730368a6..53ab9a31c5 100644 --- a/types/database/models/servers/group_membership.d.ts +++ b/types/database/models/servers/group_membership.ts @@ -1,17 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type GroupModel from './group'; import type UserModel from './user'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The GroupMembership model represents the 'association table' where many groups have users and many users are in * groups (relationship type N:N) */ -export default class GroupMembershipModel extends Model { +declare class GroupMembershipModel extends Model { /** table (name) : GroupMembership */ static table: string; @@ -39,3 +38,5 @@ export default class GroupMembershipModel extends Model { /** user : The related user */ member: Relation; } + +export default GroupMembershipModel; diff --git a/types/database/models/servers/group_team.d.ts b/types/database/models/servers/group_team.ts similarity index 84% rename from types/database/models/servers/group_team.d.ts rename to types/database/models/servers/group_team.ts index 7b22a35b58..8b37b1a79f 100644 --- a/types/database/models/servers/group_team.d.ts +++ b/types/database/models/servers/group_team.ts @@ -1,17 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type GroupModel from './group'; import type TeamModel from './team'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The GroupTeam model represents the 'association table' where many groups have teams and many teams are in * groups (relationship type N:N) */ -export default class GroupTeamModel extends Model { +declare class GroupTeamModel extends Model { /** table (name) : GroupTeam */ static table: string; @@ -39,3 +38,5 @@ export default class GroupTeamModel extends Model { /** team : The related team */ team: Relation; } + +export default GroupTeamModel; diff --git a/types/database/models/servers/my_channel.d.ts b/types/database/models/servers/my_channel.ts similarity index 91% rename from types/database/models/servers/my_channel.d.ts rename to types/database/models/servers/my_channel.ts index 61cce92e9e..34c57cad04 100644 --- a/types/database/models/servers/my_channel.d.ts +++ b/types/database/models/servers/my_channel.ts @@ -1,16 +1,14 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model from '@nozbe/watermelondb/Model'; - import type ChannelModel from './channel'; import type MyChannelSettingsModel from './my_channel_settings'; +import type {Relation, Model} from '@nozbe/watermelondb'; /** * MyChannel is an extension of the Channel model, but it lists only the Channels the app's user belongs to */ -export default class MyChannelModel extends Model { +declare class MyChannelModel extends Model { /** table (name) : MyChannel */ static table: string; @@ -49,3 +47,5 @@ export default class MyChannelModel extends Model { resetPreparedState: () => void; } + +export default MyChannelModel; diff --git a/types/database/models/servers/my_channel_settings.d.ts b/types/database/models/servers/my_channel_settings.ts similarity index 79% rename from types/database/models/servers/my_channel_settings.d.ts rename to types/database/models/servers/my_channel_settings.ts index dbdcde074c..979a2c1455 100644 --- a/types/database/models/servers/my_channel_settings.d.ts +++ b/types/database/models/servers/my_channel_settings.ts @@ -1,16 +1,14 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model from '@nozbe/watermelondb/Model'; - import type MyChannelModel from './my_channel'; +import type {Relation, Model} from '@nozbe/watermelondb'; /** * The MyChannelSettings model represents the specific user's configuration to * the channel this user belongs to. */ -export default class MyChannelSettingsModel extends Model { +declare class MyChannelSettingsModel extends Model { /** table (name) : MyChannelSettings */ static table: string; @@ -20,3 +18,5 @@ export default class MyChannelSettingsModel extends Model { /** myChannel : The relation pointing to the MY_CHANNEL table */ myChannel: Relation; } + +export default MyChannelSettingsModel; diff --git a/types/database/models/servers/my_team.d.ts b/types/database/models/servers/my_team.ts similarity index 79% rename from types/database/models/servers/my_team.d.ts rename to types/database/models/servers/my_team.ts index 6233d8c20d..41aedf9888 100644 --- a/types/database/models/servers/my_team.d.ts +++ b/types/database/models/servers/my_team.ts @@ -1,15 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model from '@nozbe/watermelondb/Model'; - import type TeamModel from './team'; +import type {Relation, Model} from '@nozbe/watermelondb'; /** * MyTeam represents only the teams that the current user belongs to */ -export default class MyTeamModel extends Model { +declare class MyTeamModel extends Model { /** table (name) : MyTeam */ static table: string; @@ -19,3 +17,5 @@ export default class MyTeamModel extends Model { /** team : The relation to the TEAM table, that this user belongs to */ team: Relation; } + +export default MyTeamModel; diff --git a/types/database/models/servers/post.d.ts b/types/database/models/servers/post.ts similarity index 93% rename from types/database/models/servers/post.d.ts rename to types/database/models/servers/post.ts index a87842e73e..a9af5704a7 100644 --- a/types/database/models/servers/post.d.ts +++ b/types/database/models/servers/post.ts @@ -1,9 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Query, Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type ChannelModel from './channel'; import type DraftModel from './draft'; import type FileModel from './file'; @@ -11,11 +8,13 @@ import type PostsInThreadModel from './posts_in_thread'; import type ReactionModel from './reaction'; import type ThreadModel from './thread'; import type UserModel from './user'; +import type {Query, Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Post model is the building block of communication in the Mattermost app. */ -export default class PostModel extends Model { +declare class PostModel extends Model { /** table (name) : Post */ static table: string; @@ -32,7 +31,7 @@ export default class PostModel extends Model { deleteAt: number; /** update_at : The timestamp to when this post was last updated on the server */ - updateAt!: number; + updateAt: number; /** edit_at : The timestamp to when this post was last edited */ editAt: number; @@ -95,3 +94,5 @@ export default class PostModel extends Model { toApi: () => Promise; } + +export default PostModel; diff --git a/types/database/models/servers/posts_in_channel.d.ts b/types/database/models/servers/posts_in_channel.ts similarity index 80% rename from types/database/models/servers/posts_in_channel.d.ts rename to types/database/models/servers/posts_in_channel.ts index 63e70b75cb..7cf24f4bf6 100644 --- a/types/database/models/servers/posts_in_channel.d.ts +++ b/types/database/models/servers/posts_in_channel.ts @@ -1,16 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type ChannelModel from './channel'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * PostsInChannel model helps us to combine adjacent posts together without leaving * gaps in between for an efficient user reading experience of posts. */ -export default class PostsInChannelModel extends Model { +declare class PostsInChannelModel extends Model { /** table (name) : PostsInChannel */ static table: string; @@ -29,3 +28,5 @@ export default class PostsInChannelModel extends Model { /** channel : The parent record of the channel for those posts */ channel: Relation; } + +export default PostsInChannelModel; diff --git a/types/database/models/servers/posts_in_thread.d.ts b/types/database/models/servers/posts_in_thread.ts similarity index 80% rename from types/database/models/servers/posts_in_thread.d.ts rename to types/database/models/servers/posts_in_thread.ts index 9a07c46f96..ff2e3801e7 100644 --- a/types/database/models/servers/posts_in_thread.d.ts +++ b/types/database/models/servers/posts_in_thread.ts @@ -1,16 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type PostModel from './post'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * PostsInThread model helps us to combine adjacent threads together without leaving * gaps in between for an efficient user reading experience for threads. */ -export default class PostsInThreadModel extends Model { +declare class PostsInThreadModel extends Model { /** table (name) : PostsInThread */ static table: string; @@ -29,3 +28,5 @@ export default class PostsInThreadModel extends Model { /** post : The related record to the parent Post model */ post: Relation; } + +export default PostsInThreadModel; diff --git a/types/database/models/servers/preference.d.ts b/types/database/models/servers/preference.ts similarity index 81% rename from types/database/models/servers/preference.d.ts rename to types/database/models/servers/preference.ts index 1d6c059c79..66d91bb2c6 100644 --- a/types/database/models/servers/preference.d.ts +++ b/types/database/models/servers/preference.ts @@ -1,16 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type UserModel from './user'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Preference model hold information about the user's preference in the app. * This includes settings about the account, the themes, etc. */ -export default class PreferenceModel extends Model { +declare class PreferenceModel extends Model { /** table (name) : Preference */ static table: string; @@ -32,3 +31,5 @@ export default class PreferenceModel extends Model { /** user : The related record to the parent User model */ user: Relation; } + +export default PreferenceModel; diff --git a/types/database/models/servers/reaction.d.ts b/types/database/models/servers/reaction.ts similarity index 84% rename from types/database/models/servers/reaction.d.ts rename to types/database/models/servers/reaction.ts index c6355d113a..9c2ad1e9ac 100644 --- a/types/database/models/servers/reaction.d.ts +++ b/types/database/models/servers/reaction.ts @@ -1,16 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type PostModel from './post'; import type UserModel from './user'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Reaction Model is used to present the reactions a user had on a particular post */ -export default class ReactionModel extends Model { +declare class ReactionModel extends Model { /** table (name) : Reaction */ static table: string; @@ -35,3 +34,5 @@ export default class ReactionModel extends Model { /** post : The related record to the Post model */ post: Relation; } + +export default ReactionModel; diff --git a/types/database/models/servers/role.d.ts b/types/database/models/servers/role.ts similarity index 77% rename from types/database/models/servers/role.d.ts rename to types/database/models/servers/role.ts index fbe2846f4a..7cb3f2696b 100644 --- a/types/database/models/servers/role.d.ts +++ b/types/database/models/servers/role.ts @@ -1,10 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Model} from '@nozbe/watermelondb'; +import type {Model} from '@nozbe/watermelondb'; /** The Role model will describe the set of permissions for each role */ -export default class RoleModel extends Model { +declare class RoleModel extends Model { /** table (name) : Role */ static table: string; @@ -14,3 +14,5 @@ export default class RoleModel extends Model { /** permissions : The different permissions associated to that role */ permissions: string[]; } + +export default RoleModel; diff --git a/types/database/models/servers/system.d.ts b/types/database/models/servers/system.ts similarity index 80% rename from types/database/models/servers/system.d.ts rename to types/database/models/servers/system.ts index 20c3b2bada..0ed5fca4b2 100644 --- a/types/database/models/servers/system.d.ts +++ b/types/database/models/servers/system.ts @@ -1,17 +1,19 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Model} from '@nozbe/watermelondb'; +import type {Model} from '@nozbe/watermelondb'; /** * The System model is another set of key-value pair combination but this one * will mostly hold configuration information about the client, the licences and some * custom data (e.g. recent emoji used) */ -export default class SystemModel extends Model { +declare class SystemModel extends Model { /** table (name) : System */ static table: string; /** value : The value for that config/information and whose key will be the id column */ value: any; } + +export default SystemModel; diff --git a/types/database/models/servers/team.d.ts b/types/database/models/servers/team.ts similarity index 91% rename from types/database/models/servers/team.d.ts rename to types/database/models/servers/team.ts index 6aec2b8d09..4e8cce42ae 100644 --- a/types/database/models/servers/team.d.ts +++ b/types/database/models/servers/team.ts @@ -7,13 +7,13 @@ import type MyTeamModel from './my_team'; import type TeamChannelHistoryModel from './team_channel_history'; import type TeamMembershipModel from './team_membership'; import type TeamSearchHistoryModel from './team_search_history'; -import type {Query, Relation} from '@nozbe/watermelondb'; -import type Model, {Associations} from '@nozbe/watermelondb/Model'; +import type {Query, Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * A Team houses and enables communication to happen across channels and users. */ -export default class TeamModel extends Model { +declare class TeamModel extends Model { /** table (name) : Team */ static table: string; @@ -30,7 +30,7 @@ export default class TeamModel extends Model { displayName: string; /** update_at : The timestamp to when this team was last updated on the server */ - updateAt!: number; + updateAt: number; /** is_group_constrained : Boolean flag indicating if members are managed groups */ isGroupConstrained: boolean; @@ -65,3 +65,5 @@ export default class TeamModel extends Model { /** teamSearchHistories : All the searches performed on this team */ teamSearchHistories: Query; } + +export default TeamModel; diff --git a/types/database/models/servers/team_channel_history.d.ts b/types/database/models/servers/team_channel_history.ts similarity index 78% rename from types/database/models/servers/team_channel_history.d.ts rename to types/database/models/servers/team_channel_history.ts index 69583ffe33..ba3f447b11 100644 --- a/types/database/models/servers/team_channel_history.d.ts +++ b/types/database/models/servers/team_channel_history.ts @@ -1,16 +1,14 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model from '@nozbe/watermelondb/Model'; - import type TeamModel from './team'; +import type {Relation, Model} from '@nozbe/watermelondb'; /** * The TeamChannelHistory model helps keeping track of the last channel visited * by the user. */ -export default class TeamChannelHistoryModel extends Model { +declare class TeamChannelHistoryModel extends Model { /** table (name) : TeamChannelHistory */ static table: string; @@ -20,3 +18,5 @@ export default class TeamChannelHistoryModel extends Model { /** team : The related record from the parent Team model */ team: Relation; } + +export default TeamChannelHistoryModel; diff --git a/types/database/models/servers/team_membership.d.ts b/types/database/models/servers/team_membership.ts similarity index 85% rename from types/database/models/servers/team_membership.d.ts rename to types/database/models/servers/team_membership.ts index 762162f731..afd4d3bfa2 100644 --- a/types/database/models/servers/team_membership.d.ts +++ b/types/database/models/servers/team_membership.ts @@ -1,17 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Query, Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type TeamModel from './team'; import type UserModel from './user'; +import type {Query, Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The TeamMembership model represents the 'association table' where many teams have users and many users are in * teams (relationship type N:N) */ -export default class TeamMembershipModel extends Model { +declare class TeamMembershipModel extends Model { /** table (name) : TeamMembership */ static table: string; @@ -43,3 +42,5 @@ export default class TeamMembershipModel extends Model { */ getAllUsersInTeam: Query; } + +export default TeamMembershipModel; diff --git a/types/database/models/servers/team_search_history.d.ts b/types/database/models/servers/team_search_history.ts similarity index 81% rename from types/database/models/servers/team_search_history.d.ts rename to types/database/models/servers/team_search_history.ts index 808134f3ab..1c4e6b7ded 100644 --- a/types/database/models/servers/team_search_history.d.ts +++ b/types/database/models/servers/team_search_history.ts @@ -1,16 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type TeamModel from './team'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The TeamSearchHistory model holds the term searched within a team. The searches are performed * at team level in the app. */ -export default class TeamSearchHistoryModel extends Model { +declare class TeamSearchHistoryModel extends Model { /** table (name) : TeamSearchHistory */ static table: string; @@ -32,3 +31,5 @@ export default class TeamSearchHistoryModel extends Model { /** team : The related record to the parent team model */ team: Relation; } + +export default TeamSearchHistoryModel; diff --git a/types/database/models/servers/thread.d.ts b/types/database/models/servers/thread.ts similarity index 87% rename from types/database/models/servers/thread.d.ts rename to types/database/models/servers/thread.ts index 466b49a892..fb3421ae17 100644 --- a/types/database/models/servers/thread.d.ts +++ b/types/database/models/servers/thread.ts @@ -1,16 +1,16 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Query, Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type PostModel from './post'; +import type ThreadInTeamModel from './thread_in_team'; import type ThreadParticipantsModel from './thread_participant'; +import type {Query, Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Thread model contains thread information of a post. */ -export default class ThreadModel extends Model { +declare class ThreadModel extends Model { /** table (name) : Thread */ static table: string; @@ -50,3 +50,5 @@ export default class ThreadModel extends Model { /** post : Query returning the post data for the current thread */ post: Relation; } + +export default ThreadModel; diff --git a/types/database/models/servers/thread_in_team.d.ts b/types/database/models/servers/thread_in_team.ts similarity index 84% rename from types/database/models/servers/thread_in_team.d.ts rename to types/database/models/servers/thread_in_team.ts index ce384d9bab..601fa09c05 100644 --- a/types/database/models/servers/thread_in_team.d.ts +++ b/types/database/models/servers/thread_in_team.ts @@ -1,18 +1,17 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type TeamModel from './team'; import type ThreadModel from './thread'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * ThreadInTeam model helps us to determine for which team we have loaded which threads * this was done mostly because of threads belonging in DM/GM channels, * so they belong in multiple teams. */ -export default class ThreadInTeamModel extends Model { +declare class ThreadInTeamModel extends Model { /** table (name) : ThreadsInTeam */ static table: string; @@ -34,3 +33,5 @@ export default class ThreadInTeamModel extends Model { /** team : The related record to the parent Team model */ team: Relation; } + +export default ThreadInTeamModel; diff --git a/types/database/models/servers/thread_participant.d.ts b/types/database/models/servers/thread_participant.ts similarity index 79% rename from types/database/models/servers/thread_participant.d.ts rename to types/database/models/servers/thread_participant.ts index d4a7ce03ac..7fe039fd43 100644 --- a/types/database/models/servers/thread_participant.d.ts +++ b/types/database/models/servers/thread_participant.ts @@ -1,16 +1,15 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {Relation} from '@nozbe/watermelondb'; -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type ThreadModel from './thread'; import type UserModel from './user'; +import type {Relation, Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; /** * The Thread Participants Model is used to show the participants of a thread */ -export default class ThreadParticipantsModel extends Model { +declare class ThreadParticipantsModel extends Model { /** table (name) : ThreadParticipants */ static table: string; @@ -29,3 +28,5 @@ export default class ThreadParticipantsModel extends Model { /** user : The related record to the User model */ user: Relation; } + +export default ThreadParticipantsModel; diff --git a/types/database/models/servers/user.d.ts b/types/database/models/servers/user.ts similarity index 93% rename from types/database/models/servers/user.d.ts rename to types/database/models/servers/user.ts index ca7ae44baa..fdfa79d9d6 100644 --- a/types/database/models/servers/user.d.ts +++ b/types/database/models/servers/user.ts @@ -1,8 +1,6 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import Model, {Associations} from '@nozbe/watermelondb/Model'; - import type ChannelModel from './channel'; import type ChannelMembershipModel from './channel_membership'; import type PostModel from './post'; @@ -10,13 +8,16 @@ import type PreferenceModel from './preference'; import type ReactionModel from './reaction'; import type TeamMembershipModel from './team_membership'; import type ThreadParticipantsModel from './thread_participant'; +import type {Model} from '@nozbe/watermelondb'; +import type {Associations} from '@nozbe/watermelondb/Model'; +import type Query from '@nozbe/watermelondb/Query'; import type {UserMentionKey} from '@typings/global/markdown'; /** * The User model represents the 'USER' table and its relationship to other * shareholders in the app. */ -export default class UserModel extends Model { +declare class UserModel extends Model { /** table (name) : User */ static table: string; @@ -27,7 +28,7 @@ export default class UserModel extends Model { authService: string; /** update_at : The timestamp at which this user account has been updated */ - updateAt!: number; + updateAt: number; /** delete_at : The timestamp at which this user account has been archived/deleted */ deleteAt: number; @@ -112,3 +113,5 @@ export default class UserModel extends Model { /* user mentions keys always excluding @channel, @all, @here */ userMentionKeys: UserMentionKey[]; } + +export default UserModel; diff --git a/types/global/error_handling.d.ts b/types/global/error_handling.ts similarity index 73% rename from types/global/error_handling.d.ts rename to types/global/error_handling.ts index 13203ad961..37351db0ee 100644 --- a/types/global/error_handling.d.ts +++ b/types/global/error_handling.ts @@ -1,7 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -interface jsAndNativeErrorHandler { +import type {ClientError} from '@utils/client_error'; + +export interface jsAndNativeErrorHandler { initializeErrorHandling: () => void; nativeErrorHandler: (e: string) => void; errorHandler: (e: Error | ClientError, isFatal: boolean) => void; diff --git a/types/global/push_notifications.d.ts b/types/global/push_notifications.d.ts index 406cc99ebf..024d46aa66 100644 --- a/types/global/push_notifications.d.ts +++ b/types/global/push_notifications.d.ts @@ -4,7 +4,7 @@ declare class Notification { fireDate?: number | string; identifier: string; - payload: any; + payload?: any; title: string; body: string; sound: string; diff --git a/types/launch/index.ts b/types/launch/index.ts index 9156e8c15d..7f8c020cd3 100644 --- a/types/launch/index.ts +++ b/types/launch/index.ts @@ -1,6 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import type {DeepLink, Launch} from '@constants'; + export interface DeepLink { serverUrl: string; teamName: string; @@ -26,31 +28,14 @@ export interface DeepLinkPlugin extends DeepLink { id: string; } -export const DeepLinkType = { - Channel: 'channel', - DirectMessage: 'dm', - GroupMessage: 'gm', - Invalid: 'invalid', - Permalink: 'permalink', - Plugin: 'plugin', -} as const; - -export type DeepLinkType = typeof DeepLinkType[keyof typeof DeepLinkType]; +export type DeepLinkType = typeof DeepLink[keyof typeof DeepLink]; export interface DeepLinkWithData { type: DeepLinkType; data?: DeepLinkChannel | DeepLinkDM | DeepLinkGM | DeepLinkPermalink | DeepLinkPlugin; } -export const LaunchType = { - AddServer: 'add-server', - Normal: 'normal', - DeepLink: 'deeplink', - Notification: 'notification', - Upgrade: 'upgrade', -} as const; - -export type LaunchType = typeof LaunchType[keyof typeof LaunchType]; +export type LaunchType = typeof Launch[keyof typeof Launch]; export interface LaunchProps { extra?: DeepLinkWithData | NotificationWithData; diff --git a/types/screens/edit_profile.d.ts b/types/screens/edit_profile.ts similarity index 52% rename from types/screens/edit_profile.d.ts rename to types/screens/edit_profile.ts index b794643be7..1a8d23231f 100644 --- a/types/screens/edit_profile.d.ts +++ b/types/screens/edit_profile.ts @@ -1,14 +1,12 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {RefObject} from 'react'; - -import {FloatingTextInputRef} from '@components/floating_text_input_label'; -import {FieldProps} from '@screens/edit_profile/components/field'; - +import type {FloatingTextInputRef} from '@components/floating_text_input_label'; +import type {FieldProps} from '@screens/edit_profile/components/field'; import type UserModel from '@typings/database/models/servers/user'; +import type {RefObject} from 'react'; -interface UserInfo extends Record { +export interface UserInfo extends Record { email: string; firstName: string; lastName: string; @@ -17,7 +15,7 @@ interface UserInfo extends Record { username: string; } -type EditProfileProps = { +export type EditProfileProps = { componentId: string; currentUser: UserModel; isModal?: boolean; @@ -29,12 +27,12 @@ type EditProfileProps = { lockedPicture: boolean; }; -type NewProfileImage = { localPath?: string; isRemoved?: boolean }; +export type NewProfileImage = { localPath?: string; isRemoved?: boolean }; -type FieldSequence = Record; isDisabled: boolean; }> -type FieldConfig = Pick +export type FieldConfig = Pick diff --git a/types/screens/gallery.d.ts b/types/screens/gallery.ts similarity index 69% rename from types/screens/gallery.d.ts rename to types/screens/gallery.ts index 931cdb9dd5..1ed1bac0b9 100644 --- a/types/screens/gallery.d.ts +++ b/types/screens/gallery.ts @@ -1,7 +1,10 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -type GalleryManagerSharedValues = { +import type {GestureHandlerGestureEvent} from 'react-native-gesture-handler'; +import type Animated from 'react-native-reanimated'; + +export type GalleryManagerSharedValues = { width: Animated.SharedValue; height: Animated.SharedValue; x: Animated.SharedValue; @@ -12,25 +15,25 @@ type GalleryManagerSharedValues = { targetHeight: Animated.SharedValue; } -type Context = { [key: string]: any }; +export type Context = { [key: string]: any }; -type Handler = ( +export type Handler = ( event: T, context: TContext, ) => void; -type onEndHandler = ( +export type onEndHandler = ( event: T, context: TContext, isCanceled: boolean, ) => void; -type ReturnHandler = ( +export type ReturnHandler = ( event: T, context: TContext, ) => R; -interface GestureHandlers { +export interface GestureHandlers { onInit?: Handler; onEvent?: Handler; shouldHandleEvent?: ReturnHandler; @@ -50,11 +53,11 @@ interface GestureHandlers { ) => void; } -type OnGestureEvent = ( +export type OnGestureEvent = ( event: T, ) => void; -type GalleryItemType = { +export type GalleryItemType = { type: 'image' | 'video' | 'file' | 'avatar'; id: string; width: number; @@ -69,4 +72,4 @@ type GalleryItemType = { postId?: string; }; -type GalleryAction = 'none' | 'downloading' | 'copying' | 'sharing' | 'opening' | 'external'; +export type GalleryAction = 'none' | 'downloading' | 'copying' | 'sharing' | 'opening' | 'external'; diff --git a/types/screens/navigation.d.ts b/types/screens/navigation.ts similarity index 70% rename from types/screens/navigation.d.ts rename to types/screens/navigation.ts index ab58fc56e5..94d5c63748 100644 --- a/types/screens/navigation.d.ts +++ b/types/screens/navigation.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {OptionsTopBarButton} from 'react-native-navigation/lib/src/interfaces/Options'; +import type {OptionsTopBarButton} from 'react-native-navigation/lib/src/interfaces/Options'; export type NavButtons = { leftButtons?: OptionsTopBarButton[]; diff --git a/types/utils/index.d.ts b/types/utils/index.d.ts deleted file mode 100644 index 75e178b63c..0000000000 --- a/types/utils/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -type Dictionary = { - [key: string]: T; -};