Merge branch 'mac-release'

This commit is contained in:
Maurice Parker 2020-03-01 16:32:31 -08:00
commit 94c6ca428f
12 changed files with 87 additions and 27 deletions

6
.gitignore vendored
View File

@ -69,7 +69,13 @@ fastlane/Preview.html
fastlane/screenshots fastlane/screenshots
fastlane/test_output fastlane/test_output
<<<<<<< HEAD
/Shared/Secrets.swift /Shared/Secrets.swift
*.py[cod] *.py[cod]
=======
/Shared/Secrets.swift
*.py[cod]
>>>>>>> mac-release

View File

@ -89,6 +89,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(inspectableObjectsDidChange(_:)), name: .InspectableObjectsDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(inspectableObjectsDidChange(_:)), name: .InspectableObjectsDidChange, object: nil)
NSWorkspace.shared.notificationCenter.addObserver(self, selector: #selector(didWakeNotification(_:)), name: NSWorkspace.didWakeNotification, object: nil)
appDelegate = self appDelegate = self
} }
@ -268,10 +269,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
} }
func applicationDidBecomeActive(_ notification: Notification) { func applicationDidBecomeActive(_ notification: Notification) {
// Its possible theres a refresh timer set to go off in the past. fireOldTimers()
// In that case, refresh now and update the timer.
refreshTimer?.fireOldTimer()
syncTimer?.fireOldTimer()
} }
func applicationDidResignActive(_ notification: Notification) { func applicationDidResignActive(_ notification: Notification) {
@ -329,6 +327,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
updateDockBadge() updateDockBadge()
} }
@objc func didWakeNotification(_ note: Notification) {
fireOldTimers()
}
// MARK: Main Window // MARK: Main Window
func windowControllerWithName(_ storyboardName: String) -> NSWindowController { func windowControllerWithName(_ storyboardName: String) -> NSWindowController {
@ -624,6 +626,13 @@ extension AppDelegate {
private extension AppDelegate { private extension AppDelegate {
func fireOldTimers() {
// Its possible theres a refresh timer set to go off in the past.
// In that case, refresh now and update the timer.
refreshTimer?.fireOldTimer()
syncTimer?.fireOldTimer()
}
func createReaderWindow() -> MainWindowController { func createReaderWindow() -> MainWindowController {
return windowControllerWithName("MainWindow") as! MainWindowController return windowControllerWithName("MainWindow") as! MainWindowController

View File

@ -58,8 +58,12 @@ final class DetailViewController: NSViewController, WKUIDelegate {
currentWebViewController = webViewController(for: mode) currentWebViewController = webViewController(for: mode)
} }
func canScrollDown(_ completion: @escaping (Bool) -> Void) { func stopMediaPlayback() {
currentWebViewController.canScrollDown(completion) currentWebViewController.stopMediaPlayback()
}
func canScrollDown(_ callback: @escaping (Bool) -> Void) {
currentWebViewController.canScrollDown(callback)
} }
override func scrollPageDown(_ sender: Any?) { override func scrollPageDown(_ sender: Any?) {

View File

@ -136,6 +136,12 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
reloadArticleImage() reloadArticleImage()
} }
// MARK: Media Functions
func stopMediaPlayback() {
webView.evaluateJavaScript("stopMediaPlayback();")
}
// MARK: Scrolling // MARK: Scrolling
func canScrollDown(_ completion: @escaping (Bool) -> Void) { func canScrollDown(_ completion: @escaping (Bool) -> Void) {

View File

@ -1,11 +1,14 @@
body { body {
margin-top: 20px; margin-top: 20px;
margin-bottom: 64px; margin-bottom: 64px;
margin-left: 64px; margin-left: auto;
margin-right: 64px; margin-right: auto;
padding-left: 64px;
padding-right: 64px;
font-family: -apple-system; font-family: -apple-system;
font-size: 18px; font-size: 18px;
word-wrap: break-word; /* break long words or URLs */ word-wrap: break-word; /* break long words or URLs */
max-width: 44em;
} }
a { a {
@ -161,7 +164,7 @@ code, pre {
padding: 0; padding: 0;
} }
img, figure, iframe, div { img, figure, div {
max-width: 100%; max-width: 100%;
height: auto !important; height: auto !important;
margin: 0 auto; margin: 0 auto;
@ -173,6 +176,11 @@ video {
margin: 0 auto; margin: 0 auto;
} }
iframe {
max-width: 100%;
margin: 0 auto;
}
figcaption { figcaption {
font-size: 14px; font-size: 14px;
line-height: 1.3em; line-height: 1.3em;
@ -239,7 +247,6 @@ img[src*="share-buttons"] {
display: none !important; display: none !important;
} }
/* Newsfoot specific styles. Structural styles come first, theme styles second */ /* Newsfoot specific styles. Structural styles come first, theme styles second */
.newsfoot-footnote-container { .newsfoot-footnote-container {
position: relative; position: relative;
@ -372,3 +379,8 @@ sup > div > a[href^='#fn']:hover {
} }
/* Site specific styles */
.wp-smiley {
height: 1em;
max-height: 1em;
}

View File

@ -457,6 +457,14 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
} }
// MARK: NSWindowDelegate
extension MainWindowController: NSWindowDelegate {
func windowWillClose(_ notification: Notification) {
detailViewController?.stopMediaPlayback()
}
}
// MARK: - SidebarDelegate // MARK: - SidebarDelegate
extension MainWindowController: SidebarDelegate { extension MainWindowController: SidebarDelegate {

View File

@ -306,7 +306,7 @@ protocol SidebarDelegate: class {
func deleteNodes(_ nodes: [Node]) { func deleteNodes(_ nodes: [Node]) {
let nodesToDelete = treeController.normalizedSelectedNodes(nodes) let nodesToDelete = treeController.normalizedSelectedNodes(nodes)
guard let undoManager = undoManager, let deleteCommand = DeleteCommand(nodesToDelete: nodesToDelete, undoManager: undoManager, errorHandler: ErrorHandler.present) else { guard let undoManager = undoManager, let deleteCommand = DeleteCommand(nodesToDelete: nodesToDelete, treeController: treeController, undoManager: undoManager, errorHandler: ErrorHandler.present) else {
return return
} }

View File

@ -31,7 +31,7 @@ class AccountsFeedbinWindowController: NSWindowController {
usernameTextField.stringValue = credentials.username usernameTextField.stringValue = credentials.username
actionButton.title = NSLocalizedString("Update", comment: "Update") actionButton.title = NSLocalizedString("Update", comment: "Update")
} else { } else {
actionButton.title = NSLocalizedString("Create", comment: "Create") actionButton.title = NSLocalizedString("Add Account", comment: "Add Account")
} }
} }

View File

@ -264,5 +264,6 @@ private extension Article {
} }
return url return url
} }
} }

View File

@ -84,6 +84,17 @@ function reloadArticleImage(imageSrc) {
image.src = imageSrc; image.src = imageSrc;
} }
function stopMediaPlayback() {
document.querySelectorAll("iframe").forEach(element => {
var iframeSrc = element.src;
element.src = iframeSrc;
});
document.querySelectorAll("video, audio").forEach(element => {
element.pause();
});
}
function error() { function error() {
document.body.innerHTML = "error"; document.body.innerHTML = "error";
} }

View File

@ -14,6 +14,7 @@ import Articles
final class DeleteCommand: UndoableCommand { final class DeleteCommand: UndoableCommand {
let treeController: TreeController?
let undoManager: UndoManager let undoManager: UndoManager
let undoActionName: String let undoActionName: String
var redoActionName: String { var redoActionName: String {
@ -23,7 +24,7 @@ final class DeleteCommand: UndoableCommand {
private let itemSpecifiers: [SidebarItemSpecifier] private let itemSpecifiers: [SidebarItemSpecifier]
init?(nodesToDelete: [Node], undoManager: UndoManager, errorHandler: @escaping (Error) -> ()) { init?(nodesToDelete: [Node], treeController: TreeController? = nil, undoManager: UndoManager, errorHandler: @escaping (Error) -> ()) {
guard DeleteCommand.canDelete(nodesToDelete) else { guard DeleteCommand.canDelete(nodesToDelete) else {
return nil return nil
@ -32,6 +33,7 @@ final class DeleteCommand: UndoableCommand {
return nil return nil
} }
self.treeController = treeController
self.undoActionName = actionName self.undoActionName = actionName
self.undoManager = undoManager self.undoManager = undoManager
self.errorHandler = errorHandler self.errorHandler = errorHandler
@ -44,8 +46,20 @@ final class DeleteCommand: UndoableCommand {
} }
func perform() { func perform() {
itemSpecifiers.forEach { $0.delete() {} }
registerUndo() let group = DispatchGroup()
itemSpecifiers.forEach {
group.enter()
$0.delete() {
group.leave()
}
}
group.notify(queue: DispatchQueue.main) {
self.treeController?.rebuild()
self.registerUndo()
}
} }
func undo() { func undo() {

View File

@ -145,17 +145,6 @@ function postRenderProcessing() {
inlineVideos(); inlineVideos();
} }
function stopMediaPlayback() {
document.querySelectorAll("iframe").forEach(element => {
var iframeSrc = element.src;
element.src = iframeSrc;
});
document.querySelectorAll("video, audio").forEach(element => {
element.pause();
});
}
window.addEventListener('DOMContentLoaded', (event) => { window.addEventListener('DOMContentLoaded', (event) => {
window.webkit.messageHandlers.domContentLoaded.postMessage(""); window.webkit.messageHandlers.domContentLoaded.postMessage("");
}); });