Skip to content

Commit

Permalink
Add support for reporting rooms on the room details screen too
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Jun 12, 2024
1 parent 94f187f commit 249478e
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ Tap the + to start adding people.";
"room_action_send_sticker" = "Send sticker";
"room_action_send_file" = "Send file";
"room_action_reply" = "Reply";
"room_action_report" = "Report room";
"room_action_report_prompt_reason" = "Reason for reporting this room";
"room_replacement_information" = "This room has been replaced and is no longer active.";
"room_replacement_link" = "The conversation continues here.";
"room_predecessor_information" = "This room is a continuation of another conversation.";
Expand Down
8 changes: 8 additions & 0 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5207,6 +5207,14 @@ public class VectorL10n: NSObject {
public static var roomActionReply: String {
return VectorL10n.tr("Vector", "room_action_reply")
}
/// Report room
public static var roomActionReport: String {
return VectorL10n.tr("Vector", "room_action_report")
}
/// Reason for reporting this room
public static var roomActionReportPromptReason: String {
return VectorL10n.tr("Vector", "room_action_report_prompt_reason")
}
/// Send file
public static var roomActionSendFile: String {
return VectorL10n.tr("Vector", "room_action_send_file")
Expand Down
3 changes: 3 additions & 0 deletions Riot/Modules/Room/RoomInfo/RoomInfoCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ extension RoomInfoCoordinator: RoomInfoListCoordinatorDelegate {
self.delegate?.roomInfoCoordinatorDidLeaveRoom(self)
}

func roomInfoListCoordinatorDidRequestReportRoom(_ coordinator: RoomInfoListCoordinatorType) {
self.delegate?.roomInfoCoordinatorDidRequestReportRoom(self)
}
}

extension RoomInfoCoordinator: RoomParticipantsViewControllerDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import MatrixSDK
func roomInfoCoordinatorBridgePresenterDelegateDidLeaveRoom(_ coordinatorBridgePresenter: RoomInfoCoordinatorBridgePresenter)
func roomInfoCoordinatorBridgePresenter(_ coordinatorBridgePresenter: RoomInfoCoordinatorBridgePresenter, didReplaceRoomWithReplacementId roomId: String)
func roomInfoCoordinatorBridgePresenter(_ coordinator: RoomInfoCoordinatorBridgePresenter, viewEventInTimeline event: MXEvent)
func roomInfoCoordinatorBridgePresenterDidRequestReportRoom(_ coordinatorBridgePresenter: RoomInfoCoordinatorBridgePresenter)
}

/// RoomInfoCoordinatorBridgePresenter enables to start RoomInfoCoordinator from a view controller.
Expand Down Expand Up @@ -131,9 +132,14 @@ extension RoomInfoCoordinatorBridgePresenter: RoomInfoCoordinatorDelegate {
func roomInfoCoordinator(_ coordinator: RoomInfoCoordinatorType, didReplaceRoomWithReplacementId roomId: String) {
self.delegate?.roomInfoCoordinatorBridgePresenter(self, didReplaceRoomWithReplacementId: roomId)
}

func roomInfoCoordinator(_ coordinator: RoomInfoCoordinatorType, viewEventInTimeline event: MXEvent) {
self.delegate?.roomInfoCoordinatorBridgePresenter(self, viewEventInTimeline: event)
}

func roomInfoCoordinatorDidRequestReportRoom(_ coordinator: RoomInfoCoordinatorType) {
self.delegate?.roomInfoCoordinatorBridgePresenterDidRequestReportRoom(self)
}
}

// MARK: - UIAdaptivePresentationControllerDelegate
Expand Down
1 change: 1 addition & 0 deletions Riot/Modules/Room/RoomInfo/RoomInfoCoordinatorType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protocol RoomInfoCoordinatorDelegate: AnyObject {
func roomInfoCoordinatorDidLeaveRoom(_ coordinator: RoomInfoCoordinatorType)
func roomInfoCoordinator(_ coordinator: RoomInfoCoordinatorType, didReplaceRoomWithReplacementId roomId: String)
func roomInfoCoordinator(_ coordinator: RoomInfoCoordinatorType, viewEventInTimeline event: MXEvent)
func roomInfoCoordinatorDidRequestReportRoom(_ coordinator: RoomInfoCoordinatorType)
}

/// `RoomInfoCoordinatorType` is a protocol describing a Coordinator that handle keybackup setup navigation flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ extension RoomInfoListCoordinator: RoomInfoListViewModelCoordinatorDelegate {
self.delegate?.roomInfoListCoordinatorDidLeaveRoom(self)
}

func roomInfoListViewModelDidRequestReportRoom(_ viewModel: RoomInfoListViewModelType) {
self.delegate?.roomInfoListCoordinatorDidRequestReportRoom(self)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protocol RoomInfoListCoordinatorDelegate: AnyObject {
func roomInfoListCoordinator(_ coordinator: RoomInfoListCoordinatorType, wantsToNavigateTo target: RoomInfoListTarget)
func roomInfoListCoordinatorDidCancel(_ coordinator: RoomInfoListCoordinatorType)
func roomInfoListCoordinatorDidLeaveRoom(_ coordinator: RoomInfoListCoordinatorType)
func roomInfoListCoordinatorDidRequestReportRoom(_ coordinator: RoomInfoListCoordinatorType)
}

/// `RoomInfoListCoordinatorType` is a protocol describing a Coordinator that handle key backup setup passphrase navigation flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ enum RoomInfoListViewAction {
case navigate(target: RoomInfoListTarget)
case leave
case cancel
case report
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,16 @@ final class RoomInfoListViewController: UIViewController {
rows: [rowLeave],
footer: nil)

let rowReport = Row(type: .destructive, icon: Asset.Images.error.image, text: VectorL10n.roomEventActionReport, accessoryType: .disclosureIndicator) {
self.viewModel.process(viewAction: .report)
}
let sectionReport = Section(header: nil,
rows: [rowReport],
footer: nil)

tmpSections.append(sectionSettings)
tmpSections.append(sectionLeave)
tmpSections.append(sectionReport)

sections = tmpSections
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ final class RoomInfoListViewModel: NSObject, RoomInfoListViewModelType {
self.leave()
case .cancel:
self.coordinatorDelegate?.roomInfoListViewModelDidCancel(self)
case .report:
self.coordinatorDelegate?.roomInfoListViewModelDidRequestReportRoom(self)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protocol RoomInfoListViewModelCoordinatorDelegate: AnyObject {
func roomInfoListViewModelDidCancel(_ viewModel: RoomInfoListViewModelType)
func roomInfoListViewModelDidLeaveRoom(_ viewModel: RoomInfoListViewModelType)
func roomInfoListViewModel(_ viewModel: RoomInfoListViewModelType, wantsToNavigateTo target: RoomInfoListTarget)
func roomInfoListViewModelDidRequestReportRoom(_ viewModel: RoomInfoListViewModelType)
}

/// Protocol describing the view model used by `RoomInfoListViewController`
Expand Down
11 changes: 8 additions & 3 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -5372,10 +5372,10 @@ - (IBAction)onButtonPressed:(id)sender
}
}

- (void)handleReportRoomButtonPress
- (void)handleReportRoom
{
// Prompt user to enter a description of the problem content.
UIAlertController *reportReasonAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionReportPromptReason]
UIAlertController *reportReasonAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomActionReportPromptReason]
message:nil
preferredStyle:UIAlertControllerStyleAlert];

Expand Down Expand Up @@ -5663,7 +5663,7 @@ - (void)roomTitleView:(RoomTitleView*)titleView recognizeTapGesture:(UITapGestur
}
else if (tappedView == previewHeader.reportButton)
{
[self handleReportRoomButtonPress];
[self handleReportRoom];
}
}

Expand Down Expand Up @@ -8032,6 +8032,11 @@ - (void)roomInfoCoordinatorBridgePresenter:(RoomInfoCoordinatorBridgePresenter *
[self reloadRoomWihtEventId:event.eventId threadId:event.threadId forceUpdateRoomMarker:NO];
}

- (void)roomInfoCoordinatorBridgePresenterDidRequestReportRoom:(RoomInfoCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
[self handleReportRoom];
}

-(void)reloadRoomWihtEventId:(NSString *)eventId
threadId:(NSString *)threadId
forceUpdateRoomMarker:(BOOL)forceUpdateRoomMarker
Expand Down
4 changes: 2 additions & 2 deletions Riot/Modules/Room/Views/Title/Preview/PreviewRoomTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ - (void)awakeFromNib
[self.rightButton setTitle:[VectorL10n join] forState:UIControlStateNormal];
[self.rightButton setTitle:[VectorL10n join] forState:UIControlStateHighlighted];

[self.reportButton setTitle:[VectorL10n roomEventActionReport] forState:UIControlStateNormal];
[self.reportButton setTitle:[VectorL10n roomEventActionReport] forState:UIControlStateHighlighted];
[self.reportButton setTitle:[VectorL10n roomActionReport] forState:UIControlStateNormal];
[self.reportButton setTitle:[VectorL10n roomActionReport] forState:UIControlStateHighlighted];

tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reportTapGesture:)];
[tap setNumberOfTouchesRequired:1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,12 @@ extension ExploreRoomCoordinator: RoomInfoCoordinatorDelegate {
self.remove(childCoordinator: coordinator)
}
}

func roomInfoCoordinator(_ coordinator: RoomInfoCoordinatorType, viewEventInTimeline event: MXEvent) {

}

func roomInfoCoordinatorDidRequestReportRoom(_ coordinator: RoomInfoCoordinatorType) {

}
}
2 changes: 1 addition & 1 deletion matrix-ios-sdk

0 comments on commit 249478e

Please sign in to comment.