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

ISS-22778: Updated DateTime parsing #1796

Merged
merged 5 commits into from
Jul 25, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,19 @@ class _ChatBottomSheetState extends State<ChatBottomSheet> {
child: const HMSEmptyChatWidget())))
: Expanded(
child: Column(children: [
Expanded(
flex: 1,
child: const PinChatWidget()),
Selector<MeetingStore, int>(
selector: (_, meetingStore) =>
meetingStore
.pinnedMessages.length,
builder:
(_, pinnedMessageLength, __) {
return pinnedMessageLength > 0
? Expanded(
flex: 1,
child:
const PinChatWidget())
: const SizedBox();
}),

/// List containing chats
Expanded(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class MessageContainer extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
children: [
HMSSubtitleText(
text: formatter.format(message.time),
text: message.time == null
? ""
: formatter.format(message.time!),
textColor: HMSThemeColors.onSurfaceMediumEmphasis,
),
const SizedBox(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class HMSMessageExtension {
if (message == null)return null
args["message_id"] = message.messageId
args["message"] = message.message
args["time"] =
SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(message.serverReceiveTime).toString()
args["time"] = message.serverReceiveTime
args["type"] = message.type
if (message.sender != null) {
args["sender"] = HMSPeerExtension.toDictionary(message.sender)!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import java.text.SimpleDateFormat

class HMSHLSCueExtension {
companion object {
fun toDictionary(hmsHlsCue: HmsHlsCue): HashMap<String, String?> {
val args = HashMap<String, String?>()
fun toDictionary(hmsHlsCue: HmsHlsCue): HashMap<String, Any?> {
val args = HashMap<String, Any?>()

args["id"] = hmsHlsCue.id
args["start_date"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsHlsCue.startDate).toString()
args["end_date"] = SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(hmsHlsCue.endDate).toString()
args["start_date"] = hmsHlsCue.startDate
args["end_date"] = hmsHlsCue.endDate
args["payload"] = hmsHlsCue.payloadval

return args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class HMSHLSCueExtension {
var dict = [String: Any?]()

dict["id"] = hmsHlsCue.id
dict["start_date"] = "\(hmsHlsCue.startDate)"
dict["start_date"] = (hmsHlsCue.startDate.timeIntervalSince1970 * 1000)
if let endDate = hmsHlsCue.endDate {
dict["end_date"] = "\(endDate)"
dict["end_date"] = (endDate.timeIntervalSince1970 * 1000)
}
dict["payload"] = hmsHlsCue.payload

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HMSMessageExtension {

dict["type"] = message.type

dict["time"] = "\(message.time)"
dict["time"] = Int(message.time.timeIntervalSince1970 * 1000)

dict["hms_message_recipient"] = HMSMessageRecipientExtension.toDictionary(message.recipient)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HMSHLSCue {
final String? id;

// startDate of the timed event
final DateTime startDate;
final DateTime? startDate;

// endDate of the timed event
final DateTime? endDate;
Expand All @@ -22,10 +22,10 @@ class HMSHLSCue {

factory HMSHLSCue.fromMap(Map map) {
return HMSHLSCue(
startDate: HMSDateExtension.convertDateFromString(map["start_date"]),
startDate: HMSDateExtension.convertDateFromEpoch(map["start_date"]),
endDate: map["end_date"] == null
? null
: HMSDateExtension.convertDateFromString(map["end_date"]),
: HMSDateExtension.convertDateFromEpoch(map["end_date"]),
id: map["id"],
payload: map["payload"]);
}
Expand Down
6 changes: 0 additions & 6 deletions packages/hmssdk_flutter/lib/src/model/hms_date_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
import 'dart:developer';

class HMSDateExtension {
///Returns DateTime object from String
static DateTime convertDateFromString(String date) {
DateTime _dateTime = DateTime.parse(date).toLocal();
return _dateTime;
}

///Returns optional DateTime object from epoch in milliseconds
static DateTime? convertDateFromEpoch(int date) {
try {
Expand Down
4 changes: 2 additions & 2 deletions packages/hmssdk_flutter/lib/src/model/hms_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HMSMessage {
final String type;

///[time] at which [sender] sent the [message]
final DateTime time;
final DateTime? time;

HMSMessageRecipient? hmsMessageRecipient;
HMSMessage(
Expand All @@ -56,7 +56,7 @@ class HMSMessage {
sender: sender,
message: messageMap['message'] as String,
type: messageMap['type'] as String,
time: HMSDateExtension.convertDateFromString(messageMap['time']),
time: HMSDateExtension.convertDateFromEpoch(messageMap['time']),
hmsMessageRecipient: recipient);
}

Expand Down