Merge pull request #486 from vincode-io/issue-367

Sorted articles by publishing date before sharing them.  Issue #367
This commit is contained in:
Brent Simmons 2018-09-26 21:35:29 -07:00 committed by GitHub
commit a0c1b63889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -363,7 +363,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
return
}
let items = selectedArticles.map { ArticlePasteboardWriter(article: $0) }
let sortedArticles = selectedArticles.sortedByDate(.orderedAscending)
let items = sortedArticles.map { ArticlePasteboardWriter(article: $0) }
let sharingServicePicker = NSSharingServicePicker(items: items)
sharingServicePicker.delegate = sharingServicePickerDelegate
sharingServicePicker.show(relativeTo: view.bounds, of: view, preferredEdge: .minY)

View File

@ -166,7 +166,8 @@ private extension TimelineViewController {
return nil
}
let items = articles.map { ArticlePasteboardWriter(article: $0) }
let sortedArticles = selectedArticles.sortedByDate(.orderedAscending)
let items = sortedArticles.map { ArticlePasteboardWriter(article: $0) }
let standardServices = NSSharingService.sharingServices(forItems: items)
let customServices = SharingServicePickerDelegate.customSharingServices(for: items)
let services = standardServices + customServices
@ -176,6 +177,7 @@ private extension TimelineViewController {
let menu = NSMenu(title: NSLocalizedString("Share", comment: "Share menu name"))
services.forEach { (service) in
service.delegate = sharingServiceDelegate
let menuItem = NSMenuItem(title: service.menuItemTitle, action: #selector(performShareServiceFromContextualMenu(_:)), keyEquivalent: "")
menuItem.image = service.image
let sharingCommandInfo = SharingCommandInfo(service: service, items: items)

View File

@ -17,6 +17,8 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
@IBOutlet var contextualMenuDelegate: TimelineContextualMenuDelegate?
@IBOutlet var dataSource: TimelineDataSource!
var sharingServiceDelegate: NSSharingServiceDelegate?
var selectedArticles: [Article] {
return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
}
@ -130,6 +132,10 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
didRegisterForNotifications = true
}
}
override func viewDidAppear() {
sharingServiceDelegate = SharingServiceDelegate(self.view.window)
}
// MARK: Appearance Change