Skip to content

Commit

Permalink
Merge pull request #43 from LikeMindsCommunity/release/v1.0.2
Browse files Browse the repository at this point in the history
Release/v1.0.2
  • Loading branch information
arnavr15 authored Apr 12, 2024
2 parents bf8bc8f + 5b7e904 commit 0fe72c2
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 118 deletions.
28 changes: 28 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Description

**Features**

**Bugs**

**What kind of change does this PR introduce?** (check at least one)
<!-- (Update "[ ]" to "[x]" to check a box) -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Hotfix (fixes a breaking changes)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Other, please describe:

### Author Checklist

- [ ] Assignee added
- [ ] Reviewer added
- [ ] Description added
- [ ] Unit test cases added

### Reviewer Checklist

- [ ] PR title starts with Jira ticket number prefix
- [ ] If hotfix, Add Hotfix as prefix in PR title
- [ ] Label added
- [ ] Commit messages follows standard format (added, changed, removed, code commented and chore)
- [ ] Description about the Feature/ Bugs added
11 changes: 4 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "example",
"version": "1.0.1",
"version": "1.0.2",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand All @@ -11,10 +11,10 @@
},
"dependencies": {
"@giphy/react-native-sdk": "2.1.3",
"@likeminds.community/chat-rn": "1.5.5",
"@likeminds.community/chat-rn-core": "1.0.1",
"@likeminds.community/chat-rn": "1.5.6",
"@likeminds.community/chat-rn-core": "1.0.2",
"@notifee/react-native": "7.6.1",
"@react-native-async-storage/async-storage": "1.18.1",
"@react-native-clipboard/clipboard": "1.11.2",
"@react-native-community/datetimepicker": "7.4.1",
"@react-native-community/slider": "4.4.3",
"@react-native-firebase/app": "18.1.0",
Expand All @@ -27,11 +27,9 @@
"@shopify/flash-list": "1.4.3",
"@types/react-native-video": "5.0.19",
"aws-sdk": "2.1380.0",
"buffer": "6.0.3",
"diff": "5.1.0",
"firebase": "9.17.1",
"lottie-react-native": "6.4.0",
"moment": "2.29.4",
"react": "18.2.0",
"react-native": "0.71.1",
"react-native-audio-recorder-player": "3.6.4",
Expand All @@ -56,7 +54,6 @@
"react-native-swiper-flatlist": "3.2.2",
"react-native-tab-view": "3.5.0",
"react-native-track-player": "4.0.1",
"react-native-uuid": "2.0.1",
"react-native-video": "5.2.1",
"realm": "11.10.2",
"rn-emoji-keyboard": "1.2.1"
Expand Down
15 changes: 15 additions & 0 deletions example/screens/Chatroom/ChatroomScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import ChatroomTabNavigator from '../../src/ChatroomTabNavigator';
import {useNavigation} from '@react-navigation/native';
import {StackNavigationProp} from '@react-navigation/stack';

interface HintMessages {
messageForRightsDisabled?: string;
messageForMemberCanMessage?: string;
messageForAnnouncementRoom?: string;
respondingDisabled?: string;
}

export function ChatroomScreen() {
const showViewParticipants = true;
const showShareChatroom = true;
Expand All @@ -25,6 +32,13 @@ export function ChatroomScreen() {
const showViewProfile = true;
const showSecretLeaveChatroom = true;
const showChatroomTopic = false;
const hintMessages: HintMessages = {
messagForMemberCanMessage:
"Sorry, at this time only CM's can message here!",
messageForRightsDisabled:
'Sorry your rights has been disabled, contact you CM for more info!',
};

const {
setChatroomTopic,
leaveChatroom,
Expand Down Expand Up @@ -158,6 +172,7 @@ export function ChatroomScreen() {
joinSecretChatroomProp={customJoinSecretChatroom}
showJoinAlertProp={customShowJoinAlert}
showRejectAlertProp={customShowRejectAlert}
hintMessages={hintMessages}
/>
</ChatRoom>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from "../constants/Strings";
import { createThumbnail } from "react-native-create-thumbnail";
import PdfThumbnail from "react-native-pdf-thumbnail";
import moment from "moment";
import { DocumentType, Events, Keys } from "../enums";
import { LMChatAnalytics } from "../analytics/LMChatAnalytics";
import { getConversationType } from "../utils/analyticsUtils";
Expand Down Expand Up @@ -614,8 +613,20 @@ export function extractPathfromRouteQuery(inputString: string): string | null {

// this function formats the date in "DD/MM/YYYY hh:mm" format
export const formatDate = (date: any, time: any) => {
const formattedTime = moment(date).format("DD/MM/YYYY hh:mm");
return formattedTime;
const inputDate = new Date(time);

// Extracting date components
const day = String(inputDate.getDate()).padStart(2, "0");
const month = String(inputDate.getMonth() + 1).padStart(2, "0");
const year = inputDate.getFullYear();

// Extracting time components
const hours = String(inputDate.getHours()).padStart(2, "0");
const minutes = String(inputDate.getMinutes()).padStart(2, "0");

// Formating date and time
const formattedDateTime = `${day}/${month}/${year} ${hours}:${minutes}`;
return formattedDateTime;
};

// this function converts seconds count to mm:ss time format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ import {
import { LMChatAnalytics } from "../../analytics/LMChatAnalytics";
import { getConversationType } from "../../utils/analyticsUtils";
import { copySelectedMessages } from "../../commonFuctions";

// TODO
// import Clipboard from "@react-native-clipboard/clipboard";

import { useAppDispatch } from "../../store";
import { VOICE_NOTE_TEXT } from "../../constants/Strings";
import AudioPlayer from "../../optionalDependecies/AudioPlayer";
import RNClipboard from "../../optionalDependecies/RNClipboard";
import CommunityClipboard from "../../optionalDependecies/CommunityClipboard";

interface ChatroomHeaderProps {
hideThreeDotsMenu?: boolean;
Expand Down Expand Up @@ -323,45 +321,57 @@ const ChatroomHeader = ({ hideThreeDotsMenu }: ChatroomHeaderProps) => {
</TouchableOpacity>
)}

{/* {len === 1 && !isFirstMessageDeleted && isCopy ? (
<TouchableOpacity
onPress={() => {
const output = copySelectedMessages(
selectedMessages,
chatroomID
);
// TODO
// Clipboard.setString(output);
dispatch({ type: SELECTED_MESSAGES, body: [] });
dispatch({ type: LONG_PRESSED, body: false });
setInitialHeader();
}}
>
<Image
source={require("../../assets/images/copy_icon3x.png")}
style={styles.threeDots}
/>
</TouchableOpacity>
) : len > 1 && isCopy ? (
<TouchableOpacity
onPress={() => {
const output = copySelectedMessages(
selectedMessages,
chatroomID
);
// TODO
// Clipboard.setString(output);
dispatch({ type: SELECTED_MESSAGES, body: [] });
dispatch({ type: LONG_PRESSED, body: false });
setInitialHeader();
}}
>
<Image
source={require("../../assets/images/copy_icon3x.png")}
style={styles.threeDots}
/>
</TouchableOpacity>
) : null} */}
{RNClipboard || CommunityClipboard ? (
<>
{len === 1 && !isFirstMessageDeleted && isCopy ? (
<TouchableOpacity
onPress={() => {
const output = copySelectedMessages(
selectedMessages,
chatroomID
);
if (RNClipboard) {
RNClipboard?.setString(output);
}
if (CommunityClipboard) {
CommunityClipboard?.setString(output);
}
dispatch({ type: SELECTED_MESSAGES, body: [] });
dispatch({ type: LONG_PRESSED, body: false });
setInitialHeader();
}}
>
<Image
source={require("../../assets/images/copy_icon3x.png")}
style={styles.threeDots}
/>
</TouchableOpacity>
) : len > 1 && isCopy ? (
<TouchableOpacity
onPress={() => {
const output = copySelectedMessages(
selectedMessages,
chatroomID
);
if (RNClipboard) {
RNClipboard?.setString(output);
}
if (CommunityClipboard) {
CommunityClipboard?.setString(output);
}
dispatch({ type: SELECTED_MESSAGES, body: [] });
dispatch({ type: LONG_PRESSED, body: false });
setInitialHeader();
}}
>
<Image
source={require("../../assets/images/copy_icon3x.png")}
style={styles.threeDots}
/>
</TouchableOpacity>
) : null}
</>
) : null}

{isSelectedMessageEditable &&
(chatroomType === ChatroomType.DMCHATROOM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Vibration,
ImageStyle,
TextStyle,
ViewStyle,
} from "react-native";
import React, { useEffect, useRef, useState } from "react";
import { styles } from "./styles";
Expand Down Expand Up @@ -437,7 +438,7 @@ const MessageInputBox = ({
const composedGesture = Gesture.Simultaneous(longPressGesture, panGesture);

// draggle mic panGesture styles
const panStyle = useAnimatedStyle(() => {
const panStyle = useAnimatedStyle((): ViewStyle | ImageStyle | TextStyle => {
return {
transform: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@ import {
} from "../../constants/Strings";
import { CustomisableMethodsContextProvider } from "../../context/CustomisableMethodsContext";

interface HintMessages {
messageForRightsDisabled?: string;
messageForMemberCanMessage?: string;
messageForAnnouncementRoom?: string;
respondingDisabled?: string;
}

interface MessageInput {
joinSecretChatroomProp: () => void;
showJoinAlertProp: () => void;
showRejectAlertProp: () => void;
hintMessages?: HintMessages;
}

const MessageInput = ({
joinSecretChatroomProp,
showJoinAlertProp,
showRejectAlertProp,
hintMessages,
}: MessageInput) => {
const {
navigation,
Expand Down Expand Up @@ -58,6 +67,10 @@ const MessageInput = ({
handleDMRejectClick,
handleFileUpload,
}: ChatroomContextValues = useChatroomContext();
const messageForRightsDisabled = hintMessages?.messageForRightsDisabled;
const messageForMemberCanMessage = hintMessages?.messageForMemberCanMessage;
const messageForAnnouncementRoom = hintMessages?.messageForAnnouncementRoom;
const respondingDisabled = hintMessages?.respondingDisabled;
return (
<View
style={{
Expand Down Expand Up @@ -92,7 +105,9 @@ const MessageInput = ({
chatroomDBDetails?.memberCanMessage === false ? (
<View style={styles.disabledInput}>
<Text style={styles.disabledInputText}>
Only Community Manager can message here.
{messageForMemberCanMessage
? messageForMemberCanMessage
: "Only Community Manager can message here."}
</Text>
</View>
) : //case to allow CM for messaging in an Announcement Room
Expand Down Expand Up @@ -120,14 +135,17 @@ const MessageInput = ({
user.state !== 1 && chatroomDBDetails?.type === 7 ? (
<View style={styles.disabledInput}>
<Text style={styles.disabledInputText}>
Only Community Manager can message here.
{messageForAnnouncementRoom
? messageForAnnouncementRoom
: "Only Community Manager can message here."}
</Text>
</View>
) : memberRights[3]?.isSelected === false ? (
<View style={styles.disabledInput}>
<Text style={styles.disabledInputText}>
The community managers have restricted you from responding
here.
{messageForRightsDisabled
? messageForRightsDisabled
: " The community managers have restricted you from responding here."}
</Text>
</View>
) : !(Object.keys(chatroomDBDetails)?.length === 0) &&
Expand Down Expand Up @@ -188,7 +206,9 @@ const MessageInput = ({
) : (
<View style={styles.disabledInput}>
<Text style={styles.disabledInputText}>
Responding is disabled
{respondingDisabled
? respondingDisabled
: "Responding is disabled"}
</Text>
</View>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ const PollConversationUI = ({
]}
>
<Text style={[styles.smallText, styles.whiteColor]}>
{hasPollEnded ? "Poll Ended" : "Poll Ends " + expiryTime}
{hasPollEnded
? "Poll Ended"
: "Poll Ends " + expiryTime + " days"}
</Text>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
POLL_MULTIPLE_STATE_MAX,
POLL_SUBMITTED_SUCCESSFULLY,
} from "../../../constants/Strings";
import moment from "moment";
import PollConversationUI from "../PollConversationUI";
import AnonymousPollModal from "../../../customModals/AnonymousPoll";
import AddOptionsModal from "../../../customModals/AddOptionModal";
Expand Down Expand Up @@ -423,6 +422,15 @@ const PollConversationView = () => {
}
};

const calculateDaysToExpiry = () => {
const difference = item?.expiryTime - Date.now();

const millisecondsInADay = 24 * 60 * 60 * 1000;
const millisecondsToDays = difference / millisecondsInADay;

return Math.ceil(millisecondsToDays)?.toString();
};

// readonly props consumed by UI component
const props: PollConversationViewState = {
text: item?.answer,
Expand All @@ -437,7 +445,7 @@ const PollConversationView = () => {
allowAddOption: allowAddOption,
shouldShowVotes: shouldShowVotes,
hasPollEnded: hasPollEnded,
expiryTime: moment(item?.expiryTime).fromNow(),
expiryTime: calculateDaysToExpiry(),
toShowResults: item?.toShowResults,
member: item?.member,
user: user,
Expand Down
Loading

0 comments on commit 0fe72c2

Please sign in to comment.