diff --git a/mobile/app.json b/mobile/app.json
index 327c3508..2f90ed5c 100644
--- a/mobile/app.json
+++ b/mobile/app.json
@@ -3,7 +3,7 @@
"name": "dsocial",
"slug": "dsocial",
"platforms": ["ios", "android"],
- "version": "1.0.2",
+ "version": "1.0.4",
"orientation": "portrait",
"scheme": "tech.berty.dsocial",
"icon": "./assets/images/icon.png",
diff --git a/mobile/app/[account]/followers.tsx b/mobile/app/[account]/followers.tsx
index e0031d23..3d2be098 100644
--- a/mobile/app/[account]/followers.tsx
+++ b/mobile/app/[account]/followers.tsx
@@ -2,13 +2,14 @@ import { selectFollowers } from "redux/features/profileSlice";
import { useAppSelector } from "@gno/redux";
import { Following } from "@gno/types";
import FollowModalContent from "@gno/components/view/follow";
+import { useRouter } from "expo-router";
export default function FollowersPage() {
const data = useAppSelector(selectFollowers);
+ const router = useRouter();
const onPress = (item: Following) => {
- // TODO: implement this function
- console.log("on press", item);
+ router.navigate({ pathname: "account", params: { accountName: item.user?.name } });
};
return ;
diff --git a/mobile/app/[account]/following.tsx b/mobile/app/[account]/following.tsx
index 0537aee7..44e5d268 100644
--- a/mobile/app/[account]/following.tsx
+++ b/mobile/app/[account]/following.tsx
@@ -2,13 +2,14 @@ import { useAppSelector } from "@gno/redux";
import { Following } from "@gno/types";
import { selectFollowing } from "redux/features/profileSlice";
import FollowModalContent from "@gno/components/view/follow";
+import { useRouter } from "expo-router";
export default function FollowingPage() {
const data = useAppSelector(selectFollowing);
+ const router = useRouter();
const onPress = (item: Following) => {
- // TODO: implement this function
- console.log("on press", item);
+ router.navigate({ pathname: "account", params: { accountName: item.user?.name } });
};
return ;
diff --git a/mobile/app/[account]/index.tsx b/mobile/app/[account]/index.tsx
index 73be9f5e..bb1b1dd0 100644
--- a/mobile/app/[account]/index.tsx
+++ b/mobile/app/[account]/index.tsx
@@ -9,6 +9,7 @@ import { setPostToReply, useAppSelector } from "@gno/redux";
import { selectAccount } from "redux/features/accountSlice";
import { setFollows } from "redux/features/profileSlice";
import { useFeed } from "@gno/hooks/use-feed";
+import { useUserCache } from "@gno/hooks/use-user-cache";
export default function Page() {
const { accountName } = useLocalSearchParams<{ accountName: string }>();
@@ -22,9 +23,11 @@ export default function Page() {
const navigation = useNavigation();
const feed = useFeed();
const search = useSearch();
- const currentUser = useAppSelector(selectAccount);
+ const userCache = useUserCache();
const dispatch = useDispatch();
+ const currentUser = useAppSelector(selectAccount);
+
useEffect(() => {
const unsubscribe = navigation.addListener("focus", async () => {
await fetchData();
@@ -49,6 +52,15 @@ export default function Page() {
const total = await feed.fetchCount(response.address);
setTotalPosts(total);
+ const enrichFollows = async (follows: Following[]) => {
+ for await (const item of follows) {
+ item.user = await userCache.getUser(item.address);
+ }
+ };
+
+ await enrichFollows(following);
+ await enrichFollows(followers);
+
dispatch(setFollows({ followers, following }));
} catch (error: unknown | Error) {
console.log(error);
@@ -61,7 +73,7 @@ export default function Page() {
router.navigate({ pathname: "account/following" });
};
- const onPressFollowers = () => {
+ const onPressFollowers = async () => {
router.navigate({ pathname: "account/followers" });
};
diff --git a/mobile/components/list/follows/follows-item.tsx b/mobile/components/list/follows/follows-item.tsx
index f375e6d1..c7a9bfe0 100644
--- a/mobile/components/list/follows/follows-item.tsx
+++ b/mobile/components/list/follows/follows-item.tsx
@@ -12,7 +12,7 @@ function FollowsItem({ item, onPress }: Props) {
onPress(item)} style={styles.container}>
- @{item.name}
+ @{item.user?.name}
{item.address}
diff --git a/mobile/redux/features/accountSlice.ts b/mobile/redux/features/accountSlice.ts
index 976269db..b4c74c8c 100644
--- a/mobile/redux/features/accountSlice.ts
+++ b/mobile/redux/features/accountSlice.ts
@@ -1,7 +1,6 @@
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import { User } from "@gno/types";
import { KeyInfo } from "@buf/gnolang_gnonative.bufbuild_es/gnonativetypes_pb";
-import { useGnoNativeContext } from "@gnolang/gnonative";
export interface CounterState {
account?: User;
diff --git a/mobile/redux/features/profileSlice.ts b/mobile/redux/features/profileSlice.ts
index b60551bd..22aef762 100644
--- a/mobile/redux/features/profileSlice.ts
+++ b/mobile/redux/features/profileSlice.ts
@@ -1,6 +1,5 @@
import { createAsyncThunk, createSlice } from "@reduxjs/toolkit";
import { Following } from "@gno/types";
-import { useUserCache } from "@gno/hooks/use-user-cache";
export interface ProfileState {
following: Following[];
@@ -20,18 +19,6 @@ interface FollowsProps {
}
export const setFollows = createAsyncThunk("profile/setFollows", async ({ following, followers }: FollowsProps, _) => {
- const cache = useUserCache();
-
- const enrichFollows = async (follows: Following[]) => {
- for await (const item of follows) {
- const user = await cache.getUser(item.address);
- item.name = user.name;
- }
- };
-
- await enrichFollows(following);
- await enrichFollows(followers);
-
return { following, followers };
});
@@ -49,6 +36,9 @@ export const profileSlice = createSlice({
state.following = action.payload.following;
state.followers = action.payload.followers;
});
+ builder.addCase(setFollows.rejected, (state, action) => {
+ console.log("Error while fetching follows, please, check the logs. %s", action.error.message);
+ });
},
});
diff --git a/mobile/src/hooks/use-search.ts b/mobile/src/hooks/use-search.ts
index 674cbf70..9b744f76 100644
--- a/mobile/src/hooks/use-search.ts
+++ b/mobile/src/hooks/use-search.ts
@@ -80,7 +80,7 @@ export const useSearch = () => {
if (excludeActiveAccount) {
// Remove the active account's own username.
const currentAccount = await gno.getActiveAccount();
- const i = usernames.indexOf(currentAccount.key.name, 0);
+ const i = usernames.indexOf(currentAccount.key?.name, 0);
if (i >= 0) {
usernames.splice(i, 1);
}
diff --git a/mobile/types.ts b/mobile/types.ts
index 2ea2443b..3909a199 100644
--- a/mobile/types.ts
+++ b/mobile/types.ts
@@ -21,15 +21,14 @@ export interface User {
}
export interface Following {
- name: string;
address: string;
started_following_at: string;
+ user?: User;
}
export interface GetJsonFollowersResult {
followers: Following[];
n_followers: number;
-
}
export interface GetJsonFollowingResult {
following: Following[];