mattermost-mobile/app/utils/thread/index.ts
Kyriakos Z 477c7cf1bf
MM-40093 [Gekidou]: adds remote action to sync threads (#6135)
* MM-40093: adds remote action to sync threads

Syncing threads fetches all unread threads if there are no threads in
the DB.
If there are threads in the DB it fetches all threads newest than the
newest one we have stored.

Fetching happens in batches of 60 threads at a time.

* Fixes querying for all threads list

* Syncs threads on WS reconnection

* Addresses review comments

* Addresses review comments
2022-04-12 15:03:05 +03:00

26 lines
1.1 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Config, Preferences} from '@constants';
import {getPreferenceValue} from '@helpers/api/preference';
import type PreferenceModel from '@typings/database/models/servers/preference';
export function isCRTEnabled(preferences: PreferenceModel[]|PreferenceType[], config?: ClientConfig): boolean {
let preferenceDefault = Preferences.COLLAPSED_REPLY_THREADS_OFF;
const configValue = config?.CollapsedThreads;
if (configValue === Config.DEFAULT_ON) {
preferenceDefault = Preferences.COLLAPSED_REPLY_THREADS_ON;
}
const preference = getPreferenceValue(preferences, Preferences.CATEGORY_DISPLAY_SETTINGS, Preferences.COLLAPSED_REPLY_THREADS, preferenceDefault);
const isAllowed = (
config?.FeatureFlagCollapsedThreads === Config.TRUE &&
config?.CollapsedThreads !== Config.DISABLED
);
return isAllowed && (
preference === Preferences.COLLAPSED_REPLY_THREADS_ON ||
config?.CollapsedThreads === Config.ALWAYS_ON
);
}