1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-26 21:55:21 +03:00

Remove NSNotificationCenter warnings

This commit is contained in:
Tae Won Ha 2023-11-13 19:29:06 +01:00
parent bdcd4f3466
commit a4c0d366f2
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
8 changed files with 37 additions and 21 deletions

View File

@ -14,6 +14,7 @@ import RxSwift
import SpriteKit
import Tabs
import UniformTypeIdentifiers
import UserNotifications
public enum FontSmoothing: String, Codable, CaseIterable {
case systemSetting

View File

@ -90,7 +90,7 @@ final class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
self.useInteractiveZshCheckbox.boolState = self.useInteractiveZsh
self.useLiveResizeCheckbox.boolState = self.useLiveResize
self.drawsParallelCheckbox.boolState = self.drawsParallel
self.nvimBinaryField.string = self.nvimBinary
self.nvimBinaryField.string = self.nvimBinary
}
private func addViews() {

View File

@ -11,6 +11,7 @@ import os
import PureLayout
import RxSwift
import Sparkle
import UserNotifications
let debugMenuItemIdentifier = NSUserInterfaceItemIdentifier("debug-menu-item")
@ -27,7 +28,7 @@ final class UpdaterDelegate: NSObject, SPUUpdaterDelegate {
}
@main
final class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {
final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
struct OpenConfig {
var urls: [URL]
var cwd: URL
@ -77,7 +78,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCent
super.init()
NSUserNotificationCenter.default.delegate = self
UNUserNotificationCenter.current().delegate = self
}
override func awakeFromNib() {
@ -440,9 +441,9 @@ extension AppDelegate {
extension AppDelegate {
func userNotificationCenter(
_: NSUserNotificationCenter,
shouldPresent _: NSUserNotification
) -> Bool { true }
_: UNUserNotificationCenter,
willPresent _: UNNotification
) async -> UNNotificationPresentationOptions { .banner }
}
// Keep the rawValues in sync with Action in the `vimr` Python script.

View File

@ -6,7 +6,7 @@
import Foundation
import WebKit
struct Defs {
enum Defs {
static let loggerSubsystem = Bundle.main.bundleIdentifier!
enum LoggerCategory {

View File

@ -9,6 +9,7 @@ import os
import PureLayout
import RxSwift
import Tabs
import UserNotifications
import Workspace
final class MainWindow: NSObject,
@ -574,16 +575,21 @@ final class MainWindow: NSObject,
}
private func showInitError() {
let notification = NSUserNotification()
notification.identifier = UUID().uuidString
notification.title = "Error during initialization"
notification.informativeText =
let content = UNMutableNotificationContent()
content.title = "Error during initialization"
content.body =
"""
There was an error during the initialization of NeoVim.
Use :messages to view the error messages.
There was an error during the initialization of NeoVim. Use :messages to view the error messages.
"""
content.sound = .default
NSUserNotificationCenter.default.deliver(notification)
let request = UNNotificationRequest(
identifier: UUID().uuidString,
content: content,
trigger: nil
)
UNUserNotificationCenter.current().add(request)
}
private func show(warning: NvimView.Warning) {

View File

@ -6,6 +6,7 @@
import Cocoa
import DictionaryCoding
import os
import UserNotifications
final class PrefMiddleware: MiddlewareType {
typealias StateType = AppState
@ -48,12 +49,19 @@ final class PrefMiddleware: MiddlewareType {
}
if !traits.contains(.monoSpace) {
let notification = NSUserNotification()
notification.identifier = UUID().uuidString
notification.title = "No monospaced font"
notification.informativeText = "The font you selected\(newFontNameText) does not seem "
let content = UNMutableNotificationContent()
content.title = "No monospaced font"
content.body = "The font you selected\(newFontNameText) does not seem "
+ "to be a monospaced font. The rendering will most likely be broken."
NSUserNotificationCenter.default.deliver(notification)
content.sound = .default
let request = UNNotificationRequest(
identifier: UUID().uuidString,
content: content,
trigger: nil
)
UNUserNotificationCenter.current().add(request)
}
}

View File

@ -6,7 +6,7 @@
import Cocoa
import NvimView
final class PrefUtils {
enum PrefUtils {
static func value<T>(from dict: [String: Any], for key: String) -> T? {
dict[key] as? T
}

View File

@ -5,7 +5,7 @@
import Foundation
final class Resources {
enum Resources {
static let resourceUrl = Bundle.main.resourceURL!
static let previewUrl = resourceUrl.appendingPathComponent("preview")