Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

feat(mobile): refetch loading previews

daniel31x13ece88eed5c0b
diff --git a/apps/mobile/app/(tabs)/collections/[id].tsx b/apps/mobile/app/(tabs)/collections/[id].tsx
index 5999f910..7508a55a 100644
--- a/apps/mobile/app/(tabs)/collections/[id].tsx
+++ b/apps/mobile/app/(tabs)/collections/[id].tsx
@@ -6,6 +6,7 @@ import {
Platform,
Text,
ActivityIndicator,
+ ViewToken,
} from "react-native";
import useAuthStore from "@/store/auth";
import LinkListing from "@/components/LinkListing";
@@ -103,6 +104,20 @@ export default function LinksScreen() {
</Text>
</View>
}
+ onViewableItemsChanged={({
+ viewableItems,
+ }: {
+ viewableItems: ViewToken[];
+ }) => {
+ const links = viewableItems.map(
+ (e) => e.item
+ ) as LinkIncludingShortenedCollectionAndTags[];
+
+ if (links.some((e) => e.id && !e.preview)) {
+ data.refetch();
+ }
+ }}
+ viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
/>
)}
</View>
diff --git a/apps/mobile/app/(tabs)/dashboard/[section].tsx b/apps/mobile/app/(tabs)/dashboard/[section].tsx
index bde076f8..9f7b5828 100644
--- a/apps/mobile/app/(tabs)/dashboard/[section].tsx
+++ b/apps/mobile/app/(tabs)/dashboard/[section].tsx
@@ -6,6 +6,7 @@ import {
Platform,
ActivityIndicator,
Text,
+ ViewToken,
} from "react-native";
import useAuthStore from "@/store/auth";
import LinkListing from "@/components/LinkListing";
@@ -110,6 +111,20 @@ export default function LinksScreen() {
</Text>
</View>
}
+ onViewableItemsChanged={({
+ viewableItems,
+ }: {
+ viewableItems: ViewToken[];
+ }) => {
+ const links = viewableItems.map(
+ (e) => e.item
+ ) as LinkIncludingShortenedCollectionAndTags[];
+
+ if (links.some((e) => e.id && !e.preview)) {
+ data.refetch();
+ }
+ }}
+ viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
/>
)}
</View>
diff --git a/apps/mobile/app/(tabs)/links/index.tsx b/apps/mobile/app/(tabs)/links/index.tsx
index 4e94d316..dd51390f 100644
--- a/apps/mobile/app/(tabs)/links/index.tsx
+++ b/apps/mobile/app/(tabs)/links/index.tsx
@@ -6,6 +6,7 @@ import {
Platform,
Text,
ActivityIndicator,
+ ViewToken,
} from "react-native";
import useAuthStore from "@/store/auth";
import LinkListing from "@/components/LinkListing";
@@ -80,6 +81,20 @@ export default function LinksScreen() {
</Text>
</View>
}
+ onViewableItemsChanged={({
+ viewableItems,
+ }: {
+ viewableItems: ViewToken[];
+ }) => {
+ const links = viewableItems.map(
+ (e) => e.item
+ ) as LinkIncludingShortenedCollectionAndTags[];
+
+ if (links.some((e) => e.id && !e.preview)) {
+ data.refetch();
+ }
+ }}
+ viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
/>
)}
</View>
diff --git a/apps/mobile/app/(tabs)/tags/[id].tsx b/apps/mobile/app/(tabs)/tags/[id].tsx
index 60ca9885..a6069ae7 100644
--- a/apps/mobile/app/(tabs)/tags/[id].tsx
+++ b/apps/mobile/app/(tabs)/tags/[id].tsx
@@ -6,6 +6,7 @@ import {
Platform,
Text,
ActivityIndicator,
+ ViewToken,
} from "react-native";
import useAuthStore from "@/store/auth";
import LinkListing from "@/components/LinkListing";
@@ -101,6 +102,20 @@ export default function LinksScreen() {
</Text>
</View>
}
+ onViewableItemsChanged={({
+ viewableItems,
+ }: {
+ viewableItems: ViewToken[];
+ }) => {
+ const links = viewableItems.map(
+ (e) => e.item
+ ) as LinkIncludingShortenedCollectionAndTags[];
+
+ if (links.some((e) => e.id && !e.preview)) {
+ data.refetch();
+ }
+ }}
+ viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
/>
)}
</View>
diff --git a/apps/mobile/components/DashboardSection.tsx b/apps/mobile/components/DashboardSection.tsx
index 445d304a..5eba6acc 100644
--- a/apps/mobile/components/DashboardSection.tsx
+++ b/apps/mobile/components/DashboardSection.tsx
@@ -1,4 +1,10 @@
-import { FlatList, Text, TouchableOpacity, View } from "react-native";
+import {
+ FlatList,
+ Text,
+ TouchableOpacity,
+ View,
+ ViewToken,
+} from "react-native";
import React from "react";
import clsx from "clsx";
import DashboardItem from "@/components/DashboardItem";
@@ -31,7 +37,7 @@ type DashboardSectionProps = {
numberOfLinks: number;
collectionsLength: number;
numberOfPinnedLinks: number;
- dashboardData: { isLoading: boolean };
+ dashboardData: { isLoading: boolean; refetch: Function };
collectionLinks?: any[];
};
@@ -129,6 +135,20 @@ const DashboardSection: React.FC<DashboardSectionProps> = ({
contentContainerStyle={{
paddingHorizontal: 20,
}}
+ onViewableItemsChanged={({
+ viewableItems,
+ }: {
+ viewableItems: ViewToken[];
+ }) => {
+ const links = viewableItems.map(
+ (e) => e.item
+ ) as LinkIncludingShortenedCollectionAndTags[];
+
+ if (links.some((e) => e.id && !e.preview)) {
+ dashboardData.refetch();
+ }
+ }}
+ viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
/>
) : (
<View className="flex-col gap-2 justify-center items-center h-40 p-10 rounded-xl bg-base-200 mx-5">
@@ -195,6 +215,20 @@ const DashboardSection: React.FC<DashboardSectionProps> = ({
contentContainerStyle={{
paddingHorizontal: 20,
}}
+ onViewableItemsChanged={({
+ viewableItems,
+ }: {
+ viewableItems: ViewToken[];
+ }) => {
+ const links = viewableItems.map(
+ (e) => e.item
+ ) as LinkIncludingShortenedCollectionAndTags[];
+
+ if (links.some((e) => e.id && !e.preview)) {
+ dashboardData.refetch();
+ }
+ }}
+ viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
/>
) : (
<View className="flex-col gap-2 justify-center items-center h-40 p-10 rounded-xl bg-base-200 mx-5">
@@ -260,6 +294,20 @@ const DashboardSection: React.FC<DashboardSectionProps> = ({
contentContainerStyle={{
paddingHorizontal: 20,
}}
+ onViewableItemsChanged={({
+ viewableItems,
+ }: {
+ viewableItems: ViewToken[];
+ }) => {
+ const links = viewableItems.map(
+ (e) => e.item
+ ) as LinkIncludingShortenedCollectionAndTags[];
+
+ if (links.some((e) => e.id && !e.preview)) {
+ dashboardData.refetch();
+ }
+ }}
+ viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
/>
) : (
<View className="flex-col gap-2 justify-center items-center h-40 p-10 rounded-xl bg-base-200 mx-5">