Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nt/editor fixes #2602

Merged
merged 4 commits into from Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -30,7 +30,7 @@ const SelectCommunityModalContainer = ({ onPressCommunity, currentAccount, onClo
callSubscribedCommunities();
}, []);

const callTopCommunities = () => dispatch(fetchCommunities('', 15, '', 'rank'));
const callTopCommunities = () => dispatch(fetchCommunities('', 15, null, 'rank'));

const callSubscribedCommunities = () => {
if (
Expand Down

This file was deleted.

@@ -0,0 +1,120 @@
import React, { useState } from 'react';
import { Text, Platform, SectionList } from 'react-native';
import { injectIntl } from 'react-intl';

import CommunityCard from '../../../communityCard';
import { SearchInput } from '../../../searchInput';
import { Separator } from '../../../basicUIElements';

import globalStyles from '../../../../globalStyles';
import styles from './selectCommunityModalStyles';
import { useEffect } from 'react';

const SelectCommunityModalView = ({
topCommunities,
subscribedCommunities,
onPressCommunity,
onChangeSearch,
onPressCloseForSearch,
searchedCommunities,
showSearchedCommunities,
currentAccount,
onCloseModal,
intl,
}) => {

const [sections, setSections] = useState<any[]>([]);



useEffect(()=>{
const _sections:any[] = [];

if (showSearchedCommunities) {
_sections.push({
data:searchedCommunities
})
} else {
if (subscribedCommunities) {
_sections.push({
sectionTitle: intl.formatMessage({ id: 'editor.my_communities' }).toUpperCase(),
data: subscribedCommunities.map((item) => ({ name: item[0], title: item[1] }))
})
}

if (!topCommunities.isLoading && !topCommunities.error && topCommunities.data?.length > 0) {
_sections.push({
sectionTitle: intl.formatMessage({ id: 'editor.top_communities' }).toUpperCase(),
data: topCommunities.data
})
}
}
setSections(_sections);

}, [showSearchedCommunities, subscribedCommunities, topCommunities, searchedCommunities])




const _listHeader = (
<>
<SearchInput
style={Platform.OS === 'android' && styles.searchInput}
onChangeText={onChangeSearch}
placeholder="search"
autoFocus={false}
backEnabled={true}
onBackPress={onCloseModal}
/>
{
!showSearchedCommunities && (
<>
<Text style={[globalStyles.label, styles.title]}>
{intl.formatMessage({ id: 'editor.my_blog' }).toUpperCase()}
</Text>
<CommunityCard
community={{
name: currentAccount.name,
title: intl.formatMessage({ id: 'editor.my_blog' }),
}}
onPress={() => onPressCommunity(null)}
/>
</>
)
}
</>
)


const _renderSectionHeader = ({ section }) => (
<Text style={[globalStyles.label, styles.title]}>
{section.sectionTitle}
</Text>
)


const _renderItem = ({ item, index, separators }) => (
<CommunityCard
community={item}
key={index.toString()}
onPress={onPressCommunity}
separators={separators}
/>
)

return (
<SectionList
style={{ flex: 1 }}
stickySectionHeadersEnabled={false}
sections={sections}
ItemSeparatorComponent={() => <Separator />}
ListHeaderComponent={_listHeader}
renderSectionHeader={_renderSectionHeader}
renderItem={_renderItem}
keyExtractor={(item, index) => index.toString()}
showsVerticalScrollIndicator={false} />

);
};

export default injectIntl(SelectCommunityModalView);
8 changes: 3 additions & 5 deletions src/components/editorElements/tagInput/view/tagInputView.tsx
Expand Up @@ -30,11 +30,9 @@ const TagInput = ({ value, handleTagChanged, intl, isPreviewActive, autoFocus, s

useEffect(() => {
// read and add tag items
if (typeof value === 'string') {
setTags(value.split(' '));
} else {
setTags(value);
}
const _tags = typeof value === 'string' ? value.split(' ') : value;
setTags(_tags.filter(t=>!!t));

}, [value]);

const _verifyTagsUpdate = (tags: string[]) => {
Expand Down