Timeline date headers
This commit is contained in:
parent
0fa069f260
commit
f9440bf594
41 changed files with 1183 additions and 771 deletions
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2019-2021 Signal Messenger, LLC
|
||||
// Copyright 2019-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { createSelector } from 'reselect';
|
||||
import { isInteger } from 'lodash';
|
||||
|
||||
import { ITEM_NAME as UNIVERSAL_EXPIRE_TIMER_ITEM } from '../../util/universalExpireTimer';
|
||||
import type { ConfigMapType } from '../../RemoteConfig';
|
||||
import type { ConfigKeyType, ConfigMapType } from '../../RemoteConfig';
|
||||
|
||||
import type { StateType } from '../reducer';
|
||||
import type { ItemsStateType } from '../ducks/items';
|
||||
|
@ -15,6 +15,7 @@ import type {
|
|||
} from '../../types/Colors';
|
||||
import { DEFAULT_CONVERSATION_COLOR } from '../../types/Colors';
|
||||
import { getPreferredReactionEmoji as getPreferredReactionEmojiFromStoredValue } from '../../reactions/preferredReactionEmoji';
|
||||
import { getIsAlpha, getIsBeta } from './user';
|
||||
|
||||
const DEFAULT_PREFERRED_LEFT_PANE_WIDTH = 320;
|
||||
|
||||
|
@ -42,15 +43,39 @@ export const getUniversalExpireTimer = createSelector(
|
|||
(state: ItemsStateType): number => state[UNIVERSAL_EXPIRE_TIMER_ITEM] || 0
|
||||
);
|
||||
|
||||
const isRemoteConfigFlagEnabled = (
|
||||
config: Readonly<ConfigMapType>,
|
||||
key: ConfigKeyType
|
||||
): boolean => Boolean(config[key]?.enabled);
|
||||
|
||||
const getRemoteConfig = createSelector(
|
||||
getItems,
|
||||
(state: ItemsStateType): ConfigMapType | undefined => state.remoteConfig
|
||||
(state: ItemsStateType): ConfigMapType => state.remoteConfig || {}
|
||||
);
|
||||
|
||||
export const getUsernamesEnabled = createSelector(
|
||||
getRemoteConfig,
|
||||
(remoteConfig?: ConfigMapType): boolean =>
|
||||
Boolean(remoteConfig?.['desktop.usernames']?.enabled)
|
||||
(remoteConfig: ConfigMapType): boolean =>
|
||||
isRemoteConfigFlagEnabled(remoteConfig, 'desktop.usernames')
|
||||
);
|
||||
|
||||
export const getAreFloatingDateHeadersEnabled = createSelector(
|
||||
getRemoteConfig,
|
||||
getIsAlpha,
|
||||
getIsBeta,
|
||||
(remoteConfig: ConfigMapType, isAlpha, isBeta): boolean => {
|
||||
if (
|
||||
isAlpha ||
|
||||
isRemoteConfigFlagEnabled(remoteConfig, 'desktop.internalUser')
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const remoteConfigKey: ConfigKeyType = isBeta
|
||||
? 'desktop.floatingDateHeaders.beta'
|
||||
: 'desktop.floatingDateHeaders.production';
|
||||
return isRemoteConfigFlagEnabled(remoteConfig, remoteConfigKey);
|
||||
}
|
||||
);
|
||||
|
||||
export const getDefaultConversationColor = createSelector(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// Copyright 2021-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import {
|
||||
|
@ -670,6 +670,7 @@ export const getBubblePropsForMessage = createSelectorCreator(memoizeByRoot)(
|
|||
(_, data): TimelineItemType => ({
|
||||
type: 'message' as const,
|
||||
data,
|
||||
timestamp: data.timestamp,
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -678,94 +679,113 @@ export function getPropsForBubble(
|
|||
message: MessageWithUIFieldsType,
|
||||
options: GetPropsForBubbleOptions
|
||||
): TimelineItemType {
|
||||
// eslint-disable-next-line camelcase
|
||||
const { received_at_ms: receivedAt, timestamp: messageTimestamp } = message;
|
||||
const timestamp = receivedAt || messageTimestamp;
|
||||
|
||||
if (isUnsupportedMessage(message)) {
|
||||
return {
|
||||
type: 'unsupportedMessage',
|
||||
data: getPropsForUnsupportedMessage(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isGroupV2Change(message)) {
|
||||
return {
|
||||
type: 'groupV2Change',
|
||||
data: getPropsForGroupV2Change(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isGroupV1Migration(message)) {
|
||||
return {
|
||||
type: 'groupV1Migration',
|
||||
data: getPropsForGroupV1Migration(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isMessageHistoryUnsynced(message)) {
|
||||
return {
|
||||
type: 'linkNotification',
|
||||
data: null,
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isExpirationTimerUpdate(message)) {
|
||||
return {
|
||||
type: 'timerNotification',
|
||||
data: getPropsForTimerNotification(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isKeyChange(message)) {
|
||||
return {
|
||||
type: 'safetyNumberNotification',
|
||||
data: getPropsForSafetyNumberNotification(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isVerifiedChange(message)) {
|
||||
return {
|
||||
type: 'verificationNotification',
|
||||
data: getPropsForVerificationNotification(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isGroupUpdate(message)) {
|
||||
return {
|
||||
type: 'groupNotification',
|
||||
data: getPropsForGroupNotification(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isEndSession(message)) {
|
||||
return {
|
||||
type: 'resetSessionNotification',
|
||||
data: null,
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isCallHistory(message)) {
|
||||
return {
|
||||
type: 'callHistory',
|
||||
data: getPropsForCallHistory(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isProfileChange(message)) {
|
||||
return {
|
||||
type: 'profileChange',
|
||||
data: getPropsForProfileChange(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isUniversalTimerNotification(message)) {
|
||||
return {
|
||||
type: 'universalTimerNotification',
|
||||
data: null,
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isChangeNumberNotification(message)) {
|
||||
return {
|
||||
type: 'changeNumberNotification',
|
||||
data: getPropsForChangeNumberNotification(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isChatSessionRefreshed(message)) {
|
||||
return {
|
||||
type: 'chatSessionRefreshed',
|
||||
data: null,
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
if (isDeliveryIssue(message)) {
|
||||
return {
|
||||
type: 'deliveryIssue',
|
||||
data: getPropsForDeliveryIssue(message, options),
|
||||
timestamp,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2019-2020 Signal Messenger, LLC
|
||||
// Copyright 2019-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { createSelector } from 'reselect';
|
||||
|
@ -9,6 +9,8 @@ import type { UUIDStringType } from '../../types/UUID';
|
|||
import type { StateType } from '../reducer';
|
||||
import type { UserStateType } from '../ducks/user';
|
||||
|
||||
import { isAlpha, isBeta } from '../../util/version';
|
||||
|
||||
export const getUser = (state: StateType): UserStateType => state.user;
|
||||
|
||||
export const getUserNumber = createSelector(
|
||||
|
@ -70,3 +72,12 @@ export const getTheme = createSelector(
|
|||
getUser,
|
||||
(state: UserStateType): ThemeType => state.theme
|
||||
);
|
||||
|
||||
const getVersion = createSelector(
|
||||
getUser,
|
||||
(state: UserStateType) => state.version
|
||||
);
|
||||
|
||||
export const getIsAlpha = createSelector(getVersion, isAlpha);
|
||||
|
||||
export const getIsBeta = createSelector(getVersion, isBeta);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue