Merge pull request #160 from loki-project/rss-feeds

Don't Auto-Join RSS Feeds
This commit is contained in:
Niels Andriesse 2020-04-20 10:53:42 +10:00 committed by GitHub
commit 66f1042d07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 6 deletions

2
Pods

@ -1 +1 @@
Subproject commit 2138c68aec1a9ca10dc9f256094e38f2f66d8334
Subproject commit 06e0efeb7131a738848fdd435d8793fc2cd1f0f5

View file

@ -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 = "<group>";
};
B8BFFF392355426100102A27 /* Messaging */ = {
B8BFFF392355426100102A27 /* Shelved */ = {
isa = PBXGroup;
children = (
24A830A12293CD0100F4CAC0 /* LokiP2PServer.swift */,
B825849F2315024B001B41CB /* LokiRSSFeedPoller.swift */,
);
path = Messaging;
path = Shelved;
sourceTree = "<group>";
};
B8C9689223FA1B05005F64E0 /* Redesign */ = {

View file

@ -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 {

View file

@ -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) {