Skip to content

Commit

Permalink
Migrate back to FlatList to allow jumping to line
Browse files Browse the repository at this point in the history
  • Loading branch information
mhoran committed Apr 9, 2024
1 parent be5feeb commit 7efcabf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 125 deletions.
132 changes: 16 additions & 116 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"dependencies": {
"@react-native-async-storage/async-storage": "1.21.0",
"@reduxjs/toolkit": "^1.9.7",
"@shopify/flash-list": "^1.6.3",
"date-fns": "^3.3.1",
"emoji-regex": "^10.3.0",
"expo": "~50.0.8",
Expand Down
13 changes: 8 additions & 5 deletions src/usecase/buffers/ui/Buffer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { Button, Text, View } from 'react-native';
import { Button, FlatList, ListRenderItem, Text, View } from 'react-native';

import { FlashList, ListRenderItem } from '@shopify/flash-list';
import { useEffect, useState } from 'react';
import { ParseShape } from 'react-native-parsed-text';
import BufferLine from './BufferLine';
Expand Down Expand Up @@ -54,7 +53,7 @@ interface State {
export default class Buffer extends React.PureComponent<Props, State> {
static readonly DEFAULT_LINE_INCREMENT = 300;

linesList = React.createRef<FlashList<WeechatLine>>();
linesList = React.createRef<FlatList<WeechatLine>>();

state = {
nickWidth: 0
Expand Down Expand Up @@ -108,21 +107,25 @@ export default class Buffer extends React.PureComponent<Props, State> {
}

return (
<FlashList
<FlatList
ref={this.linesList}
data={lines}
key={bufferId}
inverted
keyboardDismissMode="interactive"
keyExtractor={keyExtractor}
renderItem={this.renderBuffer}
initialNumToRender={35}
maxToRenderPerBatch={35}
removeClippedSubviews={true}
windowSize={15}
ListFooterComponent={
<Header
bufferId={bufferId}
lines={lines.length}
fetchMoreLines={fetchMoreLines}
/>
}
estimatedItemSize={44}
/>
);
}
Expand Down
7 changes: 4 additions & 3 deletions src/usecase/buffers/ui/BufferLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { formatDateDayChange } from '../../../lib/helpers/date-formatter';
import { cof } from '../../../lib/weechat/colors';
import Default, { styles } from './themes/Default';
import { isSameDay } from 'date-fns';
import { memo } from 'react';

interface Props {
line: WeechatLine;
Expand All @@ -28,7 +29,7 @@ const BufferLine: React.FC<Props> = ({
const showReadMarker = line.pointers.at(-1) === lastReadLine;

return (
<>
<View>
{showLine && (
<>
{showDate && (
Expand All @@ -51,8 +52,8 @@ const BufferLine: React.FC<Props> = ({
style={{ borderWidth: 1, borderColor: cof.chat_read_marker.color }}
/>
)}
</>
</View>
);
};

export default BufferLine;
export default memo(BufferLine);

0 comments on commit 7efcabf

Please sign in to comment.