Skip to content

Commit

Permalink
Activer les sondages (Polls) (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Buquet committed Sep 22, 2023
1 parent da37f78 commit 907f564
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 75 deletions.
44 changes: 21 additions & 23 deletions Riot/Modules/Room/RoomCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {

self.roomViewController.parentSpaceId = parameters.parentSpaceId

// Tchap: Disable Polls
// TimelinePollProvider.shared.session = parameters.session
TimelinePollProvider.shared.session = parameters.session
VoiceBroadcastPlaybackProvider.shared.session = parameters.session
VoiceBroadcastRecorderProvider.shared.session = parameters.session

Expand Down Expand Up @@ -479,22 +478,22 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {

private func startEditPollCoordinator(startEvent: MXEvent? = nil) {
// Tchap: Feature unavailable
// let parameters = PollEditFormCoordinatorParameters(room: roomViewController.roomDataSource.room, pollStartEvent: startEvent)
// let coordinator = PollEditFormCoordinator(parameters: parameters)
//
// coordinator.completion = { [weak self, weak coordinator] in
// guard let self = self, let coordinator = coordinator else {
// return
// }
//
// self.navigationRouter?.dismissModule(animated: true, completion: nil)
// self.remove(childCoordinator: coordinator)
// }
//
// add(childCoordinator: coordinator)
//
// navigationRouter?.present(coordinator, animated: true)
// coordinator.start()
let parameters = PollEditFormCoordinatorParameters(room: roomViewController.roomDataSource.room, pollStartEvent: startEvent)
let coordinator = PollEditFormCoordinator(parameters: parameters)

coordinator.completion = { [weak self, weak coordinator] in
guard let self = self, let coordinator = coordinator else {
return
}

self.navigationRouter?.dismissModule(animated: true, completion: nil)
self.remove(childCoordinator: coordinator)
}

add(childCoordinator: coordinator)

navigationRouter?.present(coordinator, animated: true)
coordinator.start()
}

private func startLoading() {
Expand Down Expand Up @@ -650,20 +649,19 @@ extension RoomCoordinator: RoomViewControllerDelegate {
}

func roomViewController(_ roomViewController: RoomViewController, canEndPollWithEventIdentifier eventIdentifier: String) -> Bool {
return /*TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEndPoll() ??*/ false
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEndPoll() ?? false
}

func roomViewController(_ roomViewController: RoomViewController, endPollWithEventIdentifier eventIdentifier: String) {
// Tchap: Disable polls
// TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.endPoll()
TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.endPoll()
}

func roomViewController(_ roomViewController: RoomViewController, canEditPollWithEventIdentifier eventIdentifier: String) -> Bool {
return /*TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEditPoll() ??*/ false
return TimelinePollProvider.shared.timelinePollCoordinatorForEventIdentifier(eventIdentifier)?.canEditPoll() ?? false
}

func roomViewController(_ roomViewController: RoomViewController, didRequestEditForPollWithStart startEvent: MXEvent) {
// startEditPollCoordinator(startEvent: startEvent)
startEditPollCoordinator(startEvent: startEvent)
}

func roomViewControllerDidStartLoading(_ roomViewController: RoomViewController) {
Expand Down
66 changes: 33 additions & 33 deletions Riot/Modules/Room/RoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3286,39 +3286,39 @@ - (RoomTimelineCellIdentifier)cellIdentifierForCellData:(MXKCellData*)cellData a
}
}
}
// else if (bubbleData.tag == RoomBubbleCellDataTagPoll)
// {
// if (bubbleData.isIncoming)
// {
// if (bubbleData.isPaginationFirstBubble)
// {
// cellIdentifier = RoomTimelineCellIdentifierIncomingPollWithPaginationTitle;
// }
// else if (bubbleData.shouldHideSenderInformation)
// {
// cellIdentifier = RoomTimelineCellIdentifierIncomingPollWithoutSenderInfo;
// }
// else
// {
// cellIdentifier = RoomTimelineCellIdentifierIncomingPoll;
// }
// }
// else
// {
// if (bubbleData.isPaginationFirstBubble)
// {
// cellIdentifier = RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle;
// }
// else if (bubbleData.shouldHideSenderInformation)
// {
// cellIdentifier = RoomTimelineCellIdentifierOutgoingPollWithoutSenderInfo;
// }
// else
// {
// cellIdentifier = RoomTimelineCellIdentifierOutgoingPoll;
// }
// }
// }
else if (bubbleData.tag == RoomBubbleCellDataTagPoll)
{
if (bubbleData.isIncoming)
{
if (bubbleData.isPaginationFirstBubble)
{
cellIdentifier = RoomTimelineCellIdentifierIncomingPollWithPaginationTitle;
}
else if (bubbleData.shouldHideSenderInformation)
{
cellIdentifier = RoomTimelineCellIdentifierIncomingPollWithoutSenderInfo;
}
else
{
cellIdentifier = RoomTimelineCellIdentifierIncomingPoll;
}
}
else
{
if (bubbleData.isPaginationFirstBubble)
{
cellIdentifier = RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle;
}
else if (bubbleData.shouldHideSenderInformation)
{
cellIdentifier = RoomTimelineCellIdentifierOutgoingPollWithoutSenderInfo;
}
else
{
cellIdentifier = RoomTimelineCellIdentifierOutgoingPoll;
}
}
}
// else if (bubbleData.tag == RoomBubbleCellDataTagLocation || bubbleData.tag == RoomBubbleCellDataTagLiveLocation)
// {
// if (bubbleData.isIncoming)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ - (void)registerVoiceMessageCellsForTableView:(UITableView*)tableView
- (void)registerPollCellsForTableView:(UITableView *)tableView
{
// // Incoming
// [tableView registerClass:PollIncomingBubbleCell.class forCellReuseIdentifier:PollIncomingBubbleCell.defaultReuseIdentifier];
// [tableView registerClass:PollIncomingWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:PollIncomingWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
// [tableView registerClass:PollIncomingWithPaginationTitleBubbleCell.class forCellReuseIdentifier:PollIncomingWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollIncomingBubbleCell.class forCellReuseIdentifier:PollIncomingBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollIncomingWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:PollIncomingWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollIncomingWithPaginationTitleBubbleCell.class forCellReuseIdentifier:PollIncomingWithPaginationTitleBubbleCell.defaultReuseIdentifier];
// // Outgoing
// [tableView registerClass:PollOutgoingWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:PollOutgoingWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
// [tableView registerClass:PollOutgoingWithPaginationTitleBubbleCell.class forCellReuseIdentifier:PollOutgoingWithPaginationTitleBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollOutgoingWithoutSenderInfoBubbleCell.class forCellReuseIdentifier:PollOutgoingWithoutSenderInfoBubbleCell.defaultReuseIdentifier];
[tableView registerClass:PollOutgoingWithPaginationTitleBubbleCell.class forCellReuseIdentifier:PollOutgoingWithPaginationTitleBubbleCell.defaultReuseIdentifier];
}

- (void)registerLocationCellsForTableView:(UITableView*)tableView
Expand Down Expand Up @@ -285,15 +285,15 @@ - (void)registerVoiceBroadcastRecorderCellsForTableView:(UITableView*)tableView

- (NSDictionary<NSNumber *,Class> *)pollCellsMapping
{
return @{/*
return @{
// Incoming
@(RoomTimelineCellIdentifierIncomingPoll) : PollIncomingBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithoutSenderInfo) : PollIncomingWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithPaginationTitle) : PollIncomingWithPaginationTitleBubbleCell.class,
// Outgoing
@(RoomTimelineCellIdentifierOutgoingPoll) : PollOutgoingWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithoutSenderInfo) : PollOutgoingWithoutSenderInfoBubbleCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle) : PollOutgoingWithPaginationTitleBubbleCell.class,*/
@(RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle) : PollOutgoingWithPaginationTitleBubbleCell.class,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ - (void)registerVoiceMessageCellsForTableView:(UITableView*)tableView

- (void)registerPollCellsForTableView:(UITableView*)tableView
{
// [tableView registerClass:PollPlainCell.class forCellReuseIdentifier:PollPlainCell.defaultReuseIdentifier];
// [tableView registerClass:PollWithoutSenderInfoPlainCell.class forCellReuseIdentifier:PollWithoutSenderInfoPlainCell.defaultReuseIdentifier];
// [tableView registerClass:PollWithPaginationTitlePlainCell.class forCellReuseIdentifier:PollWithPaginationTitlePlainCell.defaultReuseIdentifier];
[tableView registerClass:PollPlainCell.class forCellReuseIdentifier:PollPlainCell.defaultReuseIdentifier];
[tableView registerClass:PollWithoutSenderInfoPlainCell.class forCellReuseIdentifier:PollWithoutSenderInfoPlainCell.defaultReuseIdentifier];
[tableView registerClass:PollWithPaginationTitlePlainCell.class forCellReuseIdentifier:PollWithPaginationTitlePlainCell.defaultReuseIdentifier];
}

- (void)registerLocationCellsForTableView:(UITableView*)tableView
Expand Down Expand Up @@ -566,13 +566,13 @@ - (void)registerVoiceBroadcastRecorderCellsForTableView:(UITableView*)tableView
{
return @{
// Incoming
// @(RoomTimelineCellIdentifierIncomingPoll) : PollPlainCell.class,
// @(RoomTimelineCellIdentifierIncomingPollWithoutSenderInfo) : PollWithoutSenderInfoPlainCell.class,
// @(RoomTimelineCellIdentifierIncomingPollWithPaginationTitle) : PollWithPaginationTitlePlainCell.class,
@(RoomTimelineCellIdentifierIncomingPoll) : PollPlainCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithoutSenderInfo) : PollWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierIncomingPollWithPaginationTitle) : PollWithPaginationTitlePlainCell.class,
// Outoing
// @(RoomTimelineCellIdentifierOutgoingPoll) : PollPlainCell.class,
// @(RoomTimelineCellIdentifierOutgoingPollWithoutSenderInfo) : PollWithoutSenderInfoPlainCell.class,
// @(RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle) : PollWithPaginationTitlePlainCell.class
@(RoomTimelineCellIdentifierOutgoingPoll) : PollPlainCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithoutSenderInfo) : PollWithoutSenderInfoPlainCell.class,
@(RoomTimelineCellIdentifierOutgoingPollWithPaginationTitle) : PollWithPaginationTitlePlainCell.class
};
}

Expand Down
3 changes: 0 additions & 3 deletions Tchap/target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,9 @@ targetTemplates:
- "RoomViewController+LocationSharing.swift"
- "TimelineCells/LocationView"
- "TimelineCells/Styles/Plain/Cells/Location"
- "TimelineCells/Styles/Plain/Cells/Poll"
- "TimelineCells/Styles/Bubble/Cells/Location"
- "TimelineCells/Styles/Bubble/Cells/Poll"
- "Views/BubbleCells/KeyVerification/SizingViewHeight.swift"
- "Views/BubbleCells/Location"
- "Views/BubbleCells/Poll"
- path: ../Riot/Modules/Rooms
- path: ../Riot/Modules/Secrets
- path: ../Riot/Modules/SecureBackup
Expand Down
1 change: 1 addition & 0 deletions changelog.d/880. feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Activer les sondages (Polls)

0 comments on commit 907f564

Please sign in to comment.