signal-desktop/ts/components/leftPane/LeftPaneHelper.tsx

136 lines
3.5 KiB
TypeScript
Raw Normal View History

2022-01-27 22:12:26 +00:00
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ChangeEvent, ReactChild } from 'react';
import type { Row } from '../ConversationList';
import type { LocalizerType } from '../../types/Util';
import type {
2021-08-06 00:17:05 +00:00
DeleteAvatarFromDiskActionType,
ReplaceAvatarActionType,
SaveAvatarToDiskActionType,
} from '../../types/Avatar';
2022-11-16 20:18:02 +00:00
import type { DurationInSeconds } from '../../util/durations';
2022-06-16 19:12:50 +00:00
import type { ShowConversationType } from '../../state/ducks/conversations';
export enum FindDirection {
Up,
Down,
}
export type ToFindType = {
direction: FindDirection;
unreadOnly: boolean;
};
export abstract class LeftPaneHelper<T> {
getHeaderContents(
_: Readonly<{
i18n: LocalizerType;
showInbox: () => void;
2021-03-03 20:09:58 +00:00
startComposing: () => void;
showChooseGroupMembers: () => void;
2022-01-27 22:12:26 +00:00
}>
): null | ReactChild {
return null;
}
getSearchInput(
_: Readonly<{
clearConversationSearch: () => unknown;
clearSearch: () => unknown;
i18n: LocalizerType;
onChangeComposeSearchTerm: (
event: ChangeEvent<HTMLInputElement>
) => unknown;
updateSearchTerm: (searchTerm: string) => unknown;
2022-06-16 19:12:50 +00:00
showConversation: ShowConversationType;
}>
): null | ReactChild {
return null;
}
getBackAction(
_: Readonly<{
showInbox: () => void;
startComposing: () => void;
showChooseGroupMembers: () => void;
}>
): undefined | (() => void) {
return undefined;
}
getPreRowsNode(
_: Readonly<{
2022-01-27 22:12:26 +00:00
clearConversationSearch: () => unknown;
2021-03-03 20:09:58 +00:00
clearGroupCreationError: () => void;
2022-01-27 22:12:26 +00:00
clearSearch: () => unknown;
2021-03-03 20:09:58 +00:00
closeMaximumGroupSizeModal: () => unknown;
closeRecommendedGroupSizeModal: () => unknown;
2021-08-06 00:17:05 +00:00
composeDeleteAvatarFromDisk: DeleteAvatarFromDiskActionType;
composeReplaceAvatar: ReplaceAvatarActionType;
composeSaveAvatarToDisk: SaveAvatarToDiskActionType;
2021-03-03 20:09:58 +00:00
createGroup: () => unknown;
i18n: LocalizerType;
2022-01-27 22:12:26 +00:00
removeSelectedContact: (_: string) => unknown;
2021-09-24 00:49:05 +00:00
setComposeGroupAvatar: (_: undefined | Uint8Array) => unknown;
2022-11-16 20:18:02 +00:00
setComposeGroupExpireTimer: (_: DurationInSeconds) => void;
2022-01-27 22:12:26 +00:00
setComposeGroupName: (_: string) => unknown;
2021-08-06 00:17:05 +00:00
toggleComposeEditingAvatar: () => unknown;
2021-03-03 20:09:58 +00:00
}>
): null | ReactChild {
return null;
}
getFooterContents(
_: Readonly<{
i18n: LocalizerType;
startSettingGroupMetadata: () => void;
createGroup: () => unknown;
}>
): null | ReactChild {
return null;
}
abstract getRowCount(): number;
abstract getRow(rowIndex: number): undefined | Row;
getRowIndexToScrollTo(
_selectedConversationId: undefined | string
): undefined | number {
return undefined;
}
isScrollable(): boolean {
return true;
}
requiresFullWidth(): boolean {
return true;
}
2021-11-01 18:43:02 +00:00
onKeyDown(
_event: KeyboardEvent,
_options: Readonly<{
searchInConversation: (conversationId: string) => unknown;
selectedConversationId: undefined | string;
startSearch: () => unknown;
}>
): void {
return undefined;
}
abstract getConversationAndMessageAtIndex(
conversationIndex: number
): undefined | { conversationId: string; messageId?: string };
abstract getConversationAndMessageInDirection(
toFind: Readonly<ToFindType>,
selectedConversationId: undefined | string,
selectedMessageId: undefined | string
): undefined | { conversationId: string; messageId?: string };
abstract shouldRecomputeRowHeights(old: Readonly<T>): boolean;
}