Skip to content

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

mobile: fix recyclerlistview crash

Ammar Ahmedc20dbf115823
diff --git a/apps/mobile/patches/recyclerlistview+4.2.0.patch b/apps/mobile/patches/recyclerlistview+4.2.0.patch
index 0ce7d32e3..22b1c424c 100644
--- a/apps/mobile/patches/recyclerlistview+4.2.0.patch
+++ b/apps/mobile/patches/recyclerlistview+4.2.0.patch
@@ -1,3 +1,15 @@
+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
@@ -23,3 +35,15 @@ index 9cd3c57..e5bcb69 100644
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);