fix: no letter headings in search results conversations and adjusted height

pull/3137/head
yougotwill 8 months ago
parent f5c396ee0a
commit 87f050ae55

@ -14,6 +14,7 @@ import { StyledChooseActionTitle } from './ActionRow';
import { ContactRow, ContactRowBreak } from './ContactRow'; import { ContactRow, ContactRowBreak } from './ContactRow';
import { UserUtils } from '../../../../session/utils'; import { UserUtils } from '../../../../session/utils';
import { getThemeValue, pxValueToNumber } from '../../../../themes/globals'; import { getThemeValue, pxValueToNumber } from '../../../../themes/globals';
import { SearchResultsMergedListItem } from '../../../../state/selectors/search';
const StyledContactSection = styled.div` const StyledContactSection = styled.div`
display: flex; display: flex;
@ -68,6 +69,19 @@ const renderRow = (props: ListRowProps) => {
return <ContactRow style={style as CSSProperties} key={key} {...item} />; return <ContactRow style={style as CSSProperties} key={key} {...item} />;
}; };
export function calcContactRowHeight(
items: Array<SearchResultsMergedListItem | string | DirectContactsByNameType>,
params: Index,
overrides?: {
rowHeight?: number;
breakRowHeight?: number;
}
) {
return isString(items[params.index])
? overrides?.breakRowHeight || pxValueToNumber(getThemeValue('--contact-row-break-height'))
: overrides?.rowHeight || pxValueToNumber(getThemeValue('--contact-row-height'));
}
const unknownSection = 'unknown'; const unknownSection = 'unknown';
const ContactListItemSection = () => { const ContactListItemSection = () => {
@ -99,12 +113,6 @@ const ContactListItemSection = () => {
const length = Number(directContactsByNameWithBreaks.length); const length = Number(directContactsByNameWithBreaks.length);
const calcRowHeight = (params: Index) => {
return isString(directContactsByNameWithBreaks[params.index])
? pxValueToNumber(getThemeValue('--contact-row-break-height'))
: pxValueToNumber(getThemeValue('--contact-row-height'));
};
return ( return (
<StyledLeftPaneList key={0} style={{ width: '100%' }}> <StyledLeftPaneList key={0} style={{ width: '100%' }}>
<AutoSizer> <AutoSizer>
@ -114,7 +122,7 @@ const ContactListItemSection = () => {
className="module-left-pane__virtual-list" className="module-left-pane__virtual-list"
height={height} height={height}
rowCount={length} rowCount={length}
rowHeight={calcRowHeight} rowHeight={params => calcContactRowHeight(directContactsByNameWithBreaks, params)}
directContactsByNameWithBreaks={directContactsByNameWithBreaks} directContactsByNameWithBreaks={directContactsByNameWithBreaks}
rowRenderer={renderRow} rowRenderer={renderRow}
width={leftPaneListWidth} width={leftPaneListWidth}

@ -12,6 +12,7 @@ import {
getSearchResultsList, getSearchResultsList,
getSearchTerm, getSearchTerm,
} from '../../state/selectors/search'; } from '../../state/selectors/search';
import { calcContactRowHeight } from '../leftpane/overlay/choose-action/ContactsListWithBreaks';
const StyledSeparatorSection = styled.div<{ isSubtitle: boolean }>` const StyledSeparatorSection = styled.div<{ isSubtitle: boolean }>`
height: 36px; height: 36px;
@ -63,15 +64,16 @@ function isContact(item: SearchResultsMergedListItem): item is { contactConvoId:
const VirtualizedList = () => { const VirtualizedList = () => {
const searchResultList = useSelector(getSearchResultsList); const searchResultList = useSelector(getSearchResultsList);
return ( return (
<AutoSizer> <AutoSizer>
{({ height, width }) => ( {({ height, width }) => (
<List <List
height={height} height={height}
rowCount={searchResultList.length} rowCount={searchResultList.length}
rowHeight={rowPos => { rowHeight={params =>
return isString(searchResultList[rowPos.index]) ? 36 : 64; calcContactRowHeight(searchResultList, params, { breakRowHeight: 36 })
}} }
rowRenderer={({ index, key, style }) => { rowRenderer={({ index, key, style }) => {
const row = searchResultList[index]; const row = searchResultList[index];
if (!row) { if (!row) {

@ -99,21 +99,22 @@ export const getSearchResultsList = createSelector([getSearchResults], searchSta
); );
// add a break wherever needed // add a break wherever needed
let currentChar = ''; // let currentChar = '';
for (let i = 0; i < idsWithNameAndType.length; i++) { for (let i = 0; i < idsWithNameAndType.length; i++) {
const m = idsWithNameAndType[i]; const m = idsWithNameAndType[i];
if (m.contactConvoId === us) { if (m.contactConvoId === us) {
usIndex = i; usIndex = i;
continue; continue;
} }
if ( // we might want breaks again in future
idsWithNameAndType.length > 1 && // if (
m.displayName && // idsWithNameAndType.length > 1 &&
m.displayName[0].toLowerCase() !== currentChar // m.displayName &&
) { // m.displayName[0].toLowerCase() !== currentChar
currentChar = m.displayName[0].toLowerCase(); // ) {
builtList.push(currentChar.toUpperCase()); // currentChar = m.displayName[0].toLowerCase();
} // builtList.push(currentChar.toUpperCase());
// }
builtList.push(m); builtList.push(m);
} }

Loading…
Cancel
Save