From 478072139e8878e94911be909ea5f2d852c531c5 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 20 Apr 2020 10:47:38 +1000 Subject: [PATCH 1/2] Ditch RSS feeds for now --- Signal.xcodeproj/project.pbxproj | 6 ++-- Signal/src/AppDelegate.m | 11 ++++++- .../LokiP2PServer.swift | 0 .../LokiRSSFeedPoller.swift | 0 Signal/src/Loki/View Controllers/HomeVC.swift | 32 ++++++++++++++++++- .../Loki/API/{ => Shelved}/LokiRSSFeed.swift | 0 .../API/{ => Shelved}/LokiRSSFeedProxy.swift | 0 7 files changed, 44 insertions(+), 5 deletions(-) rename Signal/src/Loki/{Messaging => Shelved}/LokiP2PServer.swift (100%) rename Signal/src/Loki/{Messaging => Shelved}/LokiRSSFeedPoller.swift (100%) rename SignalServiceKit/src/Loki/API/{ => Shelved}/LokiRSSFeed.swift (100%) rename SignalServiceKit/src/Loki/API/{ => Shelved}/LokiRSSFeedProxy.swift (100%) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 8ce780ff1..4622db904 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -2786,7 +2786,7 @@ isa = PBXGroup; children = ( B8CCF63B239757C10091D419 /* Components */, - B8BFFF392355426100102A27 /* Messaging */, + B8BFFF392355426100102A27 /* Shelved */, B8CCF63C239757DB0091D419 /* Utilities */, B8CCF63D2397580E0091D419 /* View Controllers */, ); @@ -2833,13 +2833,13 @@ path = Loki; sourceTree = ""; }; - B8BFFF392355426100102A27 /* Messaging */ = { + B8BFFF392355426100102A27 /* Shelved */ = { isa = PBXGroup; children = ( 24A830A12293CD0100F4CAC0 /* LokiP2PServer.swift */, B825849F2315024B001B41CB /* LokiRSSFeedPoller.swift */, ); - path = Messaging; + path = Shelved; sourceTree = ""; }; B8C9689223FA1B05005F64E0 /* Redesign */ = { diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 0c0b46db3..c16ab5e6b 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -1486,7 +1486,9 @@ static BOOL isInternalTestVersion = NO; - (void)createRSSFeedsIfNeeded { - NSArray *feeds = @[ /*self.lokiNewsFeed,*/ self.lokiMessengerUpdatesFeed ]; + return; + /* + NSArray *feeds = @[ self.lokiNewsFeed, self.lokiMessengerUpdatesFeed ]; NSString *userHexEncodedPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey; for (LKRSSFeed *feed in feeds) { NSString *userDefaultsKey = [@"isRSSFeedSetUp." stringByAppendingString:feed.id]; @@ -1501,10 +1503,13 @@ static BOOL isInternalTestVersion = NO; [NSUserDefaults.standardUserDefaults setBool:YES forKey:userDefaultsKey]; } } + */ } - (void)createRSSFeedPollersIfNeeded { + return; + /* // Only create the RSS feed pollers if their threads aren't deleted __block TSGroupThread *lokiNewsFeedThread; [OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { @@ -1517,13 +1522,17 @@ static BOOL isInternalTestVersion = NO; if (self.lokiMessengerUpdatesFeedPoller == nil) { self.lokiMessengerUpdatesFeedPoller = [[LKRSSFeedPoller alloc] initForFeed:self.lokiMessengerUpdatesFeed]; } + */ } - (void)startRSSFeedPollersIfNeeded { + return; + /* [self createRSSFeedPollersIfNeeded]; if (self.lokiNewsFeedPoller != nil) { [self.lokiNewsFeedPoller startIfNeeded]; } if (self.lokiMessengerUpdatesFeedPoller != nil) { [self.lokiMessengerUpdatesFeedPoller startIfNeeded]; } + */ } - (void)handleThreadDeleted:(NSNotification *)notification { diff --git a/Signal/src/Loki/Messaging/LokiP2PServer.swift b/Signal/src/Loki/Shelved/LokiP2PServer.swift similarity index 100% rename from Signal/src/Loki/Messaging/LokiP2PServer.swift rename to Signal/src/Loki/Shelved/LokiP2PServer.swift diff --git a/Signal/src/Loki/Messaging/LokiRSSFeedPoller.swift b/Signal/src/Loki/Shelved/LokiRSSFeedPoller.swift similarity index 100% rename from Signal/src/Loki/Messaging/LokiRSSFeedPoller.swift rename to Signal/src/Loki/Shelved/LokiRSSFeedPoller.swift diff --git a/Signal/src/Loki/View Controllers/HomeVC.swift b/Signal/src/Loki/View Controllers/HomeVC.swift index d2b42b17a..c9690c678 100644 --- a/Signal/src/Loki/View Controllers/HomeVC.swift +++ b/Signal/src/Loki/View Controllers/HomeVC.swift @@ -18,6 +18,10 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol }() private let editingDatabaseConnection = OWSPrimaryStorage.shared().newDatabaseConnection() + + private var threadCount: UInt { + threads.numberOfItems(inGroup: TSInboxGroup) + } // MARK: Components private lazy var seedReminderView: SeedReminderView = { @@ -55,6 +59,25 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol result.isUserInteractionEnabled = false return result }() + + private lazy var emptyStateView: UIView = { + let explanationLabel = UILabel() + explanationLabel.textColor = Colors.text + explanationLabel.font = .systemFont(ofSize: Values.smallFontSize) + explanationLabel.numberOfLines = 0 + explanationLabel.lineBreakMode = .byWordWrapping + explanationLabel.textAlignment = .center + explanationLabel.text = NSLocalizedString("You don't have any contacts yet", comment: "") + let createNewPrivateChatButton = Button(style: .prominentOutline, size: .large) + createNewPrivateChatButton.setTitle(NSLocalizedString("Start a Session", comment: ""), for: UIControl.State.normal) + createNewPrivateChatButton.addTarget(self, action: #selector(createNewPrivateChat), for: UIControl.Event.touchUpInside) + createNewPrivateChatButton.set(.width, to: 180) + let result = UIStackView(arrangedSubviews: [ explanationLabel, createNewPrivateChatButton ]) + result.axis = .vertical + result.spacing = Values.mediumSpacing + result.alignment = .center + return result + }() // MARK: Lifecycle override func viewDidLoad() { @@ -107,6 +130,11 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol fadeView.pin(.top, to: .top, of: view, withInset: topInset) fadeView.pin(.trailing, to: .trailing, of: view) fadeView.pin(.bottom, to: .bottom, of: view) + // Set up empty state view + view.addSubview(emptyStateView) + emptyStateView.center(.horizontal, in: view) + let verticalCenteringConstraint = emptyStateView.center(.vertical, in: view) + verticalCenteringConstraint.constant = -16 // Makes things appear centered visually // Set up search bar // tableView.tableHeaderView = searchBar // searchBar.sizeToFit() @@ -164,7 +192,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol // MARK: Data func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return Int(threads.numberOfItems(inGroup: TSInboxGroup)) + return Int(threadCount) } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { @@ -184,6 +212,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol self.threads.update(with: transaction) } tableView.reloadData() + emptyStateView.isHidden = threadCount != 0 } @objc private func handleYapDatabaseModifiedExternallyNotification(_ notification: Notification) { @@ -222,6 +251,7 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol } } tableView.endUpdates() + emptyStateView.isHidden = threadCount != 0 } @objc private func handleApplicationDidBecomeActiveNotification(_ notification: Notification) { diff --git a/SignalServiceKit/src/Loki/API/LokiRSSFeed.swift b/SignalServiceKit/src/Loki/API/Shelved/LokiRSSFeed.swift similarity index 100% rename from SignalServiceKit/src/Loki/API/LokiRSSFeed.swift rename to SignalServiceKit/src/Loki/API/Shelved/LokiRSSFeed.swift diff --git a/SignalServiceKit/src/Loki/API/LokiRSSFeedProxy.swift b/SignalServiceKit/src/Loki/API/Shelved/LokiRSSFeedProxy.swift similarity index 100% rename from SignalServiceKit/src/Loki/API/LokiRSSFeedProxy.swift rename to SignalServiceKit/src/Loki/API/Shelved/LokiRSSFeedProxy.swift From 58cfd0d9241bb56d3b299b8cb657f244d04ec7e0 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Mon, 20 Apr 2020 10:52:15 +1000 Subject: [PATCH 2/2] Update Pods --- Pods | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pods b/Pods index 2138c68ae..06e0efeb7 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit 2138c68aec1a9ca10dc9f256094e38f2f66d8334 +Subproject commit 06e0efeb7131a738848fdd435d8793fc2cd1f0f5