Skip to content

Commit

Permalink
Merge pull request #2741 from ecency/nt/waves-fixes
Browse files Browse the repository at this point in the history
Nt/waves fixes
  • Loading branch information
feruzm authored Aug 31, 2023
2 parents 6a3b2fe + d62f049 commit 80c0bf2
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 22 deletions.
13 changes: 11 additions & 2 deletions src/components/comments/container/commentsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useNavigation } from '@react-navigation/native';
import { getComments, deleteComment } from '../../../providers/hive/dhive';
// Services and Actions
import { writeToClipboard } from '../../../utils/clipboard';
import { toastNotification } from '../../../redux/actions/uiAction';
import { showProfileModal, toastNotification } from '../../../redux/actions/uiAction';

// Middleware

Expand Down Expand Up @@ -171,7 +171,7 @@ const CommentsContainer = ({
handleOnCommentsLoaded();
}
})
.catch(() => {});
.catch(() => { });
}
};

Expand Down Expand Up @@ -243,6 +243,14 @@ const CommentsContainer = ({
});
};


const _handleOnUserPress = (username) => {
if (username) {
dispatch(showProfileModal(username))
}

}

const _openReplyThread = (comment) => {
postsCachePrimer.cachePost(comment);
navigation.navigate({
Expand Down Expand Up @@ -298,6 +306,7 @@ const CommentsContainer = ({
handleDeleteComment={_handleDeleteComment}
handleOnPressCommentMenu={_handleOnPressCommentMenu}
handleOnOptionsPress={handleOnOptionsPress}
handleOnUserPress={_handleOnUserPress}
isOwnProfile={isOwnProfile}
isHideImage={isHideImage}
handleOnVotersPress={_handleOnVotersPress}
Expand Down
56 changes: 38 additions & 18 deletions src/components/quickReplyModal/quickReplyModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React, {
forwardRef,
useCallback,
Fragment,
useMemo,
} from 'react';
import EStyleSheet from 'react-native-extended-stylesheet';
import {
Expand Down Expand Up @@ -44,6 +45,8 @@ export interface QuickReplyModalContentProps {
onClose: () => void;
}

const MAX_BODY_LENGTH = 250;

export const QuickReplyModalContent = forwardRef(
({
mode,
Expand Down Expand Up @@ -82,6 +85,11 @@ export const QuickReplyModalContent = forwardRef(
? `${currentAccount.name}/ecency.waves` //TODO: update author based on selected host
: `${currentAccount.name}/${parentAuthor}/${parentPermlink}`; // different draftId for each user acount


const bodyLengthExceeded = useMemo(
() => commentValue.length > MAX_BODY_LENGTH && mode === 'wave',
[commentValue, mode]);

useImperativeHandle(ref, () => ({
handleSheetClose() {
_addQuickCommentIntoCache();
Expand Down Expand Up @@ -312,28 +320,40 @@ export const QuickReplyModalContent = forwardRef(
}


const _renderExpandBtn = () => (
<View style={styles.toolbarContainer}>
<IconButton
iconType="MaterialsIcons"
name="image-outline"
onPress={_handleMediaBtn}
size={24}
color={EStyleSheet.value('$primaryBlack')}
/>
{mode !== 'wave' && (
const _renderExpandBtn = () => {

const _lengthTextStyle = {
...styles.toolbarSpacer,
color: EStyleSheet.value(bodyLengthExceeded ? '$primaryRed' : '$iconColor')
}

return (
<View style={styles.toolbarContainer}>
<IconButton
iconStyle={styles.expandIcon}
iconType="MaterialCommunityIcons"
name="arrow-expand"
onPress={_handleExpandBtn}
iconType="MaterialsIcons"
name="image-outline"
onPress={_handleMediaBtn}
size={24}
color={EStyleSheet.value('$primaryBlack')}
/>
)}
{mode !== 'wave' ? (
<IconButton
iconStyle={styles.toolbarSpacer}
iconType="MaterialCommunityIcons"
name="arrow-expand"
onPress={_handleExpandBtn}
size={24}
color={EStyleSheet.value('$primaryBlack')}
/>
) : (
<Text style={_lengthTextStyle}>
{`${commentValue.length}/${MAX_BODY_LENGTH}`}
</Text>
)}

</View>
);
</View>
);
}



Expand All @@ -354,7 +374,7 @@ export const QuickReplyModalContent = forwardRef(
text={intl.formatMessage({
id: _titleId,
})}
isDisable={isUploading}
isDisable={isUploading || bodyLengthExceeded}
isLoading={postSubmitter.isSending}
/>
</View>
Expand Down
6 changes: 4 additions & 2 deletions src/components/quickReplyModal/quickReplyModalStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ export default EStyleSheet.create({
} as ViewStyle,
toolbarContainer:{
flexDirection:'row',
alignItems:'center'
} as ViewStyle,
expandIcon:{
toolbarSpacer:{
marginLeft:8
} as ViewStyle
} as ViewStyle,

});

0 comments on commit 80c0bf2

Please sign in to comment.