Page MenuHomePhabricator

D13997.id45934.diff
No OneTemporary

D13997.id45934.diff

diff --git a/native/navigation/community-drawer-content.react.js b/native/navigation/community-drawer-content.react.js
--- a/native/navigation/community-drawer-content.react.js
+++ b/native/navigation/community-drawer-content.react.js
@@ -7,6 +7,8 @@
import { SafeAreaView } from 'react-native-safe-area-context';
import {
+ fetchAllCommunityInfosWithNamesActionTypes,
+ fetchAllCommunityInfosWithNames,
fetchCommunityInfosActionTypes,
useFetchCommunityInfos,
} from 'lib/actions/community-actions.js';
@@ -15,7 +17,9 @@
useFetchPrimaryInviteLinks,
} from 'lib/actions/link-actions.js';
import { useChildThreadInfosMap } from 'lib/hooks/thread-hooks.js';
+import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
import { communityThreadSelector } from 'lib/selectors/thread-selectors.js';
+import type { ClientCommunityInfoWithCommunityName } from 'lib/types/community-types.js';
import { threadTypeIsCommunityRoot } from 'lib/types/thread-types-enum.js';
import {
createRecursiveDrawerItemsData,
@@ -25,11 +29,15 @@
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import CommunityDrawerItem from './community-drawer-item.react.js';
-import { CommunityCreationRouteName } from './route-names.js';
+import {
+ CommunityCreationRouteName,
+ CommunityJoinerModalRouteName,
+} from './route-names.js';
import { useNavigateToThread } from '../chat/message-list-types.js';
import SWMansionIcon from '../components/swmansion-icon.react.js';
import { useSelector } from '../redux/redux-utils.js';
import { useStyles } from '../themes/colors.js';
+import Alert from '../utils/alert.js';
import {
flattenDrawerItemsData,
filterOutThreadAndDescendantIDs,
@@ -53,6 +61,11 @@
const dispatchActionPromise = useDispatchActionPromise();
const drawerStatus = useDrawerStatus();
+ const fetchPromise = useLegacyAshoatKeyserverCall(
+ fetchAllCommunityInfosWithNames,
+ );
+ const [fetchedCommunitiesWithNames, setFetchedCommunitiesWithNames] =
+ React.useState<?$ReadOnlyArray<ClientCommunityInfoWithCommunityName>>(null);
React.useEffect(() => {
if (drawerStatus !== 'open') {
return;
@@ -65,11 +78,20 @@
fetchCommunityInfosActionTypes,
fetchCommunityInfos(),
);
+ void dispatchActionPromise(
+ fetchAllCommunityInfosWithNamesActionTypes,
+ fetchPromise(),
+ );
+ void (async () => {
+ const response = await fetchPromise();
+ setFetchedCommunitiesWithNames(response.allCommunityInfosWithNames);
+ })();
}, [
callFetchPrimaryLinks,
dispatchActionPromise,
drawerStatus,
fetchCommunityInfos,
+ fetchPromise,
]);
const [expanded, setExpanded] = React.useState<Set<string>>(() => {
@@ -169,10 +191,29 @@
</TouchableOpacity>
);
+ const onPressExploreCommunities = React.useCallback(() => {
+ if (!fetchedCommunitiesWithNames) {
+ Alert.alert(
+ 'Couldn’t load communities',
+ 'Uhh... try again?',
+ [{ text: 'OK' }],
+ {
+ cancelable: false,
+ },
+ );
+ return;
+ }
+
+ navigate<'CommunityJoinerModal'>({
+ name: CommunityJoinerModalRouteName,
+ params: { communities: fetchedCommunitiesWithNames },
+ });
+ }, [fetchedCommunitiesWithNames, navigate]);
+
let exploreCommunitiesButton;
if (__DEV__) {
exploreCommunitiesButton = (
- <TouchableOpacity activeOpacity={0.4}>
+ <TouchableOpacity onPress={onPressExploreCommunities} activeOpacity={0.4}>
<View style={styles.exploreCommunitiesContainer}>
<View style={styles.exploreCommunitiesIconContainer}>
<SWMansionIcon

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 6:39 AM (4 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693837
Default Alt Text
D13997.id45934.diff (3 KB)

Event Timeline