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

feat: Hand Raise sorting based on Time #1812

Merged
merged 2 commits into from
Aug 29, 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
33 changes: 33 additions & 0 deletions packages/hms_room_kit/lib/src/meeting/meeting_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -666,16 +666,45 @@ class MeetingStore extends ChangeNotifier
void toggleLocalPeerHandRaise() {
if (isRaisedHand) {
_hmsSDKInteractor.lowerLocalPeerHand(hmsActionResultListener: this);
resetTimestampWhenHandDown();
} else {
_hmsSDKInteractor.raiseLocalPeerHand(hmsActionResultListener: this);
setTimestampWhenHandRaise();
}
}

void setTimestampWhenHandRaise() {
int currentTime = DateTime.now().millisecondsSinceEpoch;
log("Vkohli Setting timestamp for hand raise $currentTime");
_hmsSDKInteractor.changeMetadata(
metadata:
"{\"isBRBOn\":false,\"prevRole\":\"$previousRole\",\"handRaisedAt\":${currentTime}}",
hmsActionResultListener: this);
}

void resetTimestampWhenHandDown() {
_hmsSDKInteractor.changeMetadata(
metadata: "{\"isBRBOn\":false,\"prevRole\":\"$previousRole\"}",
hmsActionResultListener: this);
}

void lowerRemotePeerHand(HMSPeer forPeer) {
_hmsSDKInteractor.lowerRemotePeerHand(
forPeer: forPeer, hmsActionResultListener: this);
}

int _getTimestampFromPeerMetadata(String? metadata) {
if (metadata == null) {
return 0;
}
try {
Map<String, dynamic> metadataMap = jsonDecode(metadata);
return metadataMap["handRaisedAt"];
} catch (e) {
return 0;
}
}

bool isBRB = false;

void changeMetadataBRB() {
Expand Down Expand Up @@ -1604,6 +1633,10 @@ class MeetingStore extends ChangeNotifier
(handDownPeer) => handDownPeer.peer.peerId == peer.peerId);
participantsInMeetingMap[peer.role.name]?[index].updatePeer(peer);
}
participantsInMeetingMap["Hand Raised"]?.sort((a, b) {
return _getTimestampFromPeerMetadata(a.peer.metadata)
.compareTo(_getTimestampFromPeerMetadata(b.peer.metadata));
});
notifyListeners();
} else if (peerUpdate == HMSPeerUpdate.metadataChanged) {
participantsInMeetingMap[peer.role.name]?[index].updatePeer(peer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
);
}

bool isHandRaisedRow(String role) {
return role == "Hand Raised";
}

Widget _kebabMenu(HMSPeer peer) {
final meetingStore = context.read<MeetingStore>();
PeerTrackNode? peerTrackNode;
Expand Down Expand Up @@ -410,12 +414,13 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
.keys
.elementAt(index);
return Selector<MeetingStore,
Tuple2<int, List<ParticipantsStore>?>>(
selector: (_, meetingStore) => Tuple2(
Tuple3<int, List<ParticipantsStore>?, String>>(
selector: (_, meetingStore) => Tuple3(
meetingStore
.participantsInMeetingMap[role]?.length ??
0,
meetingStore.participantsInMeetingMap[role]),
meetingStore.participantsInMeetingMap[role],
role),
builder: (_, participantsPerRole, __) {
return (participantsPerRole.item2?.isNotEmpty ??
false)
Expand Down Expand Up @@ -458,7 +463,9 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
null
? 0
: (participantsPerRole.item1) *
54,
(isHandRaisedRow(role)
? 60
: 54),
child: Center(
child: ListView.builder(
physics:
Expand Down Expand Up @@ -538,15 +545,18 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
isSIPPeer,
__) {
return isSIPPeer
? CircleAvatar(
radius: 16,
backgroundColor: HMSThemeColors.surfaceBright,
child: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/sip_call.svg",
height: 12,
width: 12,
colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn),
))
? Padding(
padding: const EdgeInsets.only(right: 4.0),
child: CircleAvatar(
radius: 12,
backgroundColor: HMSThemeColors.surfaceDefault,
child: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/sip_call.svg",
height: 12,
width: 12,
colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn),
)),
)
: const SizedBox();
},
selector: (_, participantsStore) =>
Expand All @@ -562,14 +572,14 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
builder: (_, participantData, __) {
return participantData.item1 != -1 && participantData.item1 < 3 && participantData.item2
? Padding(
padding: const EdgeInsets.only(right: 16.0),
padding: const EdgeInsets.only(right: 4.0),
child: CircleAvatar(
radius: 16,
radius: 12,
backgroundColor: HMSThemeColors.surfaceDefault,
child: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/network_${participantData.item1}.svg",
height: 16,
width: 16,
height: 12,
width: 12,
),
),
)
Expand All @@ -588,12 +598,12 @@ class _ParticipantsBottomSheetState extends State<ParticipantsBottomSheet> {
? Padding(
padding: const EdgeInsets.only(right: 16.0),
child: CircleAvatar(
radius: 16,
radius: 12,
backgroundColor: HMSThemeColors.surfaceDefault,
child: SvgPicture.asset(
"packages/hms_room_kit/lib/src/assets/icons/hand_outline.svg",
height: 16,
width: 16,
height: 12,
width: 12,
colorFilter: ColorFilter.mode(HMSThemeColors.onSurfaceHighEmphasis, BlendMode.srcIn),
),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/hmssdk_flutter/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ SPEC CHECKSUMS:
FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_foreground_task: 21ef182ab0a29a3005cc72cd70e5f45cb7f7f817
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleMLKit: 2bd0dc6253c4d4f227aad460f69215a504b2980e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1340;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = 100ms;
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down