mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 10:52:16 +03:00
fixed action modal not appear on second press
This commit is contained in:
parent
b934e85255
commit
395df42470
@ -30,19 +30,20 @@ const DraftsScreen = ({
|
||||
const [selectedId, setSelectedId] = useState(null);
|
||||
const ActionSheetRef = useRef(null);
|
||||
const firstMount = useRef(true);
|
||||
const selectedIdRef = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
if (firstMount.current) {
|
||||
firstMount.current = false;
|
||||
return;
|
||||
selectedIdRef.current = selectedId;
|
||||
}, [selectedId])
|
||||
|
||||
|
||||
const _onActionPress = (index) => {
|
||||
if(index === 0){
|
||||
moveScheduleToDraft(selectedIdRef.current)
|
||||
}
|
||||
if (ActionSheetRef.current) {
|
||||
ActionSheetRef.current.show();
|
||||
}
|
||||
}, [selectedId]);
|
||||
}
|
||||
|
||||
// Component Functions
|
||||
|
||||
const _renderItem = (item, type) => {
|
||||
const tags = item.tags ? item.tags.split(/[ ,]+/) : [];
|
||||
const tag = tags[0] || '';
|
||||
@ -51,6 +52,18 @@ const DraftsScreen = ({
|
||||
const summary = postBodySummary({ ...item, last_update: item.modified }, 100);
|
||||
const isSchedules = type === 'schedules';
|
||||
|
||||
const _onItemPress = () => {
|
||||
if(isSchedules){
|
||||
setSelectedId(item._id)
|
||||
if(ActionSheetRef.current){
|
||||
ActionSheetRef.current.show();
|
||||
}
|
||||
}else {
|
||||
editDraft(item._id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<DraftListItem
|
||||
created={isSchedules ? getFormatedCreatedDate(item.schedule) : item.created}
|
||||
@ -62,7 +75,7 @@ const DraftsScreen = ({
|
||||
thumbnail={thumbnail ? { uri: thumbnail } : null}
|
||||
username={currentAccount.name}
|
||||
reputation={currentAccount.reputation}
|
||||
handleOnPressItem={() => (isSchedules ? setSelectedId(item._id) : editDraft(item._id))}
|
||||
handleOnPressItem={_onItemPress}
|
||||
handleOnRemoveItem={isSchedules ? removeSchedule : removeDraft}
|
||||
id={item._id}
|
||||
key={item._id}
|
||||
@ -151,9 +164,7 @@ const DraftsScreen = ({
|
||||
}),
|
||||
]}
|
||||
cancelButtonIndex={1}
|
||||
onPress={(index) => {
|
||||
index === 0 && moveScheduleToDraft(selectedId);
|
||||
}}
|
||||
onPress={_onActionPress}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user