Signal-iOS/SignalUI/Utils/OWSProfileManager+SignalUI.m
Nora Trapp 7bd167f815
Initial story sending support
* Little fix for context menu

* Add 'My Stories' section to stories tab

* Add new story thread types

* Show stories in conversation picker

* Support for sending stories

* Update story list when sending stories

* Add basic 'My Stories' view controller

* Initial stories settings screens

* Consolidate TSPrivateStoryThread and TSMyStoryThread into one class

* Require an explicit read transaction to initialize an outgoing message

* Fix linting

* Allow enabling group story from internal settings

* Fix tests

* PR Feedback
2022-06-10 22:28:03 -04:00

57 lines
2.2 KiB
Objective-C

//
// Copyright (c) 2022 Open Whisper Systems. All rights reserved.
//
#import "OWSProfileManager+SignalUI.h"
#import <SignalUI/SignalUI-Swift.h>
NS_ASSUME_NONNULL_BEGIN
@implementation OWSProfileManager (SignalUI)
- (void)presentAddThreadToProfileWhitelist:(TSThread *)thread
fromViewController:(UIViewController *)fromViewController
success:(void (^)(void))successHandler
{
OWSAssertIsOnMainThread();
ActionSheetController *actionSheet = [[ActionSheetController alloc] init];
NSString *shareTitle = OWSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE",
@"Button to confirm that user wants to share their profile with a user or group.");
[actionSheet
addAction:[[ActionSheetAction alloc] initWithTitle:shareTitle
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"share_profile")
style:ActionSheetActionStyleDefault
handler:^(ActionSheetAction *_Nonnull action) {
[self userAddedThreadToProfileWhitelist:thread];
successHandler();
}]];
[actionSheet addAction:[OWSActionSheets cancelAction]];
[fromViewController presentActionSheet:actionSheet];
}
- (void)userAddedThreadToProfileWhitelist:(TSThread *)thread
{
OWSAssertIsOnMainThread();
BOOL isFeatureEnabled = NO;
if (!isFeatureEnabled) {
OWSLogWarn(@"skipping sending profile-key message because the feature is not yet fully available.");
[OWSProfileManager.shared addThreadToProfileWhitelist:thread];
return;
}
[OWSProfileManager.shared addThreadToProfileWhitelist:thread];
DatabaseStorageWrite(self.databaseStorage, ^(SDSAnyWriteTransaction *transaction) {
OWSProfileKeyMessage *message = [[OWSProfileKeyMessage alloc] initWithThread:thread transaction:transaction];
[self.messageSenderJobQueue addMessage:message.asPreparer transaction:transaction];
});
}
@end
NS_ASSUME_NONNULL_END