Skip to content

Commit

Permalink
Require macOS 10.15
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 24, 2021
1 parent e719add commit 62aa1e1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 30 deletions.
30 changes: 10 additions & 20 deletions HypeMachineAPI/MiscRouter.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
import Foundation
import CryptoKit
import Alamofire
import var CommonCrypto.CC_MD5_DIGEST_LENGTH
import func CommonCrypto.CC_MD5
import typealias CommonCrypto.CC_LONG

// TODO: Replace this with CryptoKit when targeting macOS 10.15.
func MD5(string: String) -> Data {
let length = Int(CC_MD5_DIGEST_LENGTH)
let messageData = string.data(using: .utf8)!
var digestData = Data(count: length)

_ = digestData.withUnsafeMutableBytes { digestBytes -> UInt8 in
messageData.withUnsafeBytes { messageBytes -> UInt8 in
if let messageBytesBaseAddress = messageBytes.baseAddress, let digestBytesBlindMemory = digestBytes.bindMemory(to: UInt8.self).baseAddress {
let messageLength = CC_LONG(messageData.count)
CC_MD5(messageBytesBaseAddress, messageLength, digestBytesBlindMemory)
}
extension String {
var data: Data { Data(utf8) }
}

return 0
}
}

return digestData
extension Data {
func md5() -> Self {
Data(Insecure.MD5.hash(data: self))
}
}


extension Router {
public enum Misc: URLRequestConvertible {
case getToken(usernameOrEmail: String, password: String)
Expand Down Expand Up @@ -58,8 +49,7 @@ extension Router {
}

func deviceID() -> String {
let serialNumber = getSerialNumber()!
return MD5(string: serialNumber).map { String(format: "%02hhx", $0) }.joined()
getSerialNumber()!.data.md5().map { String(format: "%02hhx", $0) }.joined()
}

func getSerialNumber() -> String? {
Expand Down
4 changes: 2 additions & 2 deletions Plug.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
MACOSX_DEPLOYMENT_TARGET = 10.15.6;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -1479,7 +1479,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14.4;
MACOSX_DEPLOYMENT_TARGET = 10.15.6;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_VERSION = 5.0;
Expand Down
4 changes: 2 additions & 2 deletions Plug/AudioPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class AudioPlayer: NSObject {
var hasPreviousTrack: Bool { previousTrack != nil }

override init() {
self.isShuffle = UserDefaults.standard.value(forKey: "shuffle") as! Bool
self.isShuffle = UserDefaults.standard.value(forKey: "shuffle") as? Bool ?? false
super.init()

bind(NSBindingName("volume"), to: NSUserDefaultsController.shared, withKeyPath: "values.volume", options: nil)
Expand Down Expand Up @@ -129,7 +129,7 @@ final class AudioPlayer: NSObject {
return
}

// TODO: Remove this and enable the below when notifications on macOS shows the attachment. (not working as of macOS 11.1)
// TODO: Remove this and enable the below when notifications on macOS shows the attachment. (not working as of macOS 11.5)
notify()

// guard
Expand Down
8 changes: 5 additions & 3 deletions Plug/TracksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,14 @@ class TracksViewController: DataSourceViewController {
}

func trackAboveOrBelow(_ track: HypeMachineAPI.Track, tracksDataSource: TracksDataSource) -> StickyTrackPosition {
guard tracksDataSource == self.tracksDataSource else {
guard
tracksDataSource == self.tracksDataSource,
let row = tracksDataSource.indexOfTrack(track),
let firstVisibleRow = tableView.visibleRows[safe: 0]
else {
return .bottom
}

let row = tracksDataSource.indexOfTrack(track)!
let firstVisibleRow = tableView.visibleRows[0]
let firstFullyVisibleRow = isTableViewRowFullyVisible(firstVisibleRow) ? firstVisibleRow : firstVisibleRow + 1
return row < firstFullyVisibleRow ? .top : .bottom
}
Expand Down
10 changes: 8 additions & 2 deletions Plug/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,6 @@ extension Int {
}


@available(macOS 10.15, *)
extension Font {
/// The default system font size.
static let systemFontSize = NSFont.systemFontSize.double
Expand All @@ -794,7 +793,6 @@ extension Font {
}
}

@available(macOS 10.15, *)
extension Font {
/// The default small system font size.
static let smallSystemFontSize = NSFont.smallSystemFontSize.double
Expand All @@ -807,3 +805,11 @@ extension Font {
system(size: smallSystemFontSize.cgFloat, weight: weight, design: design)
}
}


extension Collection {
/// Returns the element at the specified index if it is within bounds, otherwise nil.
subscript(safe index: Index) -> Element? {
indices.contains(index) ? self[index] : nil
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

[![](https://tools.applemediaservices.com/api/badges/download-on-the-mac-app-store/black/en-us?size=250x83&releaseDate=1615852800)](https://apps.apple.com/app/id1514182074)

Requires macOS 10.14 or later.
Requires macOS 10.15 or later.

## Screenshot

Expand Down

0 comments on commit 62aa1e1

Please sign in to comment.