Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: minor improvement in list

Ammar Ahmed756259c907d1
diff --git a/apps/mobile/app/components/list/list-item.wrapper.tsx b/apps/mobile/app/components/list/list-item.wrapper.tsx
index 4ce3fbc55..01c4d034b 100644
--- a/apps/mobile/app/components/list/list-item.wrapper.tsx
+++ b/apps/mobile/app/components/list/list-item.wrapper.tsx
@@ -117,14 +117,21 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
}
currentItemId.current = resolvedItem.item.id;
setItem(resolvedItem.item);
+ }
+
+ if (resolvedItem?.group) {
setGroupHeader(resolvedItem.group);
+ } else {
+ setGroupHeader(undefined);
}
}, []);
if (previousIndex.current !== index) {
previousIndex.current = index;
const resolvedItem = items?.cacheItem(index);
- refreshItem(resolvedItem);
+ if (resolvedItem) {
+ refreshItem(resolvedItem);
+ }
}
useEffect(() => {
@@ -132,12 +139,15 @@ export function ListItemWrapper(props: ListItemWrapperProps) {
try {
clearTimeout(refreshTimeout.current);
const idx = index;
- refreshTimeout.current = setTimeout(async () => {
- if (idx !== previousIndex.current) return;
- const resolvedItem = await items?.item(idx, resolveItems);
- if (idx !== previousIndex.current) return;
- refreshItem(resolvedItem);
- }, 100);
+ refreshTimeout.current = setTimeout(
+ async () => {
+ if (idx !== previousIndex.current) return;
+ const resolvedItem = await items?.item(idx, resolveItems);
+ if (idx !== previousIndex.current) return;
+ refreshItem(resolvedItem);
+ },
+ items?.cacheItem(index) ? 100 : 0
+ );
} catch (e) {
console.log("Error", e);
}
diff --git a/apps/mobile/patches/recyclerlistview+4.2.0.patch b/apps/mobile/patches/recyclerlistview+4.2.0.patch
deleted file mode 100644
index 22b1c424c..000000000
--- a/apps/mobile/patches/recyclerlistview+4.2.0.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-diff --git a/node_modules/recyclerlistview/dist/reactnative/core/RecyclerListView.js b/node_modules/recyclerlistview/dist/reactnative/core/RecyclerListView.js
-index a98072e..b455a90 100644
---- a/node_modules/recyclerlistview/dist/reactnative/core/RecyclerListView.js
-+++ b/node_modules/recyclerlistview/dist/reactnative/core/RecyclerListView.js
-@@ -584,6 +584,7 @@ var RecyclerListView = /** @class */ (function (_super) {
- var dataIndex = itemMeta.dataIndex;
- if (!ts_object_utils_1.ObjectUtil.isNullOrUndefined(dataIndex) && dataIndex < dataSize) {
- var itemRect = this._virtualRenderer.getLayoutManager().getLayouts()[dataIndex];
-+ if (!itemRect) return null;
- var data = this.props.dataProvider.getDataForIndex(dataIndex);
- var type = this.props.layoutProvider.getLayoutTypeForIndex(dataIndex);
- var key = this._virtualRenderer.syncAndGetKey(dataIndex);
-diff --git a/node_modules/recyclerlistview/dist/reactnative/core/layoutmanager/LayoutManager.js b/node_modules/recyclerlistview/dist/reactnative/core/layoutmanager/LayoutManager.js
-index 9cd3c57..e5bcb69 100644
---- a/node_modules/recyclerlistview/dist/reactnative/core/layoutmanager/LayoutManager.js
-+++ b/node_modules/recyclerlistview/dist/reactnative/core/layoutmanager/LayoutManager.js
-@@ -111,7 +111,7 @@ var WrapGridLayoutManager = /** @class */ (function (_super) {
- var itemDim = { height: 0, width: 0 };
- var itemRect = null;
- var oldLayout = null;
-- for (var i = startIndex; i < itemCount; i++) {
-+ for (var i = startIndex; i < Math.min(startIndex + 500, itemCount); i++) {
- oldLayout = this._layouts[i];
- var layoutType = this._layoutProvider.getLayoutTypeForIndex(i);
- if (oldLayout && oldLayout.isOverridden && oldLayout.type === layoutType) {
-@@ -184,6 +184,11 @@ var WrapGridLayoutManager = /** @class */ (function (_super) {
- }
- var i = startIndex - 1;
- for (; i >= 0; i--) {
-+
-+ if (!this._layouts[i]) {
-+ break;
-+ }
-+
- if (this._isHorizontal) {
- if (this._layouts[i].y === 0) {
- break;
-diff --git a/node_modules/recyclerlistview/src/core/RecyclerListView.tsx b/node_modules/recyclerlistview/src/core/RecyclerListView.tsx
-index 95dd87b..bf982e8 100644
---- a/node_modules/recyclerlistview/src/core/RecyclerListView.tsx
-+++ b/node_modules/recyclerlistview/src/core/RecyclerListView.tsx
-@@ -670,6 +670,7 @@ export default class RecyclerListView<P extends RecyclerListViewProps, S extends
- private _renderRowUsingMeta(itemMeta: RenderStackItem): JSX.Element | null {
- const dataSize = this.props.dataProvider.getSize();
- const dataIndex = itemMeta.dataIndex;
-+
- if (!ObjectUtil.isNullOrUndefined(dataIndex) && dataIndex < dataSize) {
- const itemRect = (this._virtualRenderer.getLayoutManager() as LayoutManager).getLayouts()[dataIndex];
- const data = this.props.dataProvider.getDataForIndex(dataIndex);