Skip to content
Permalink
Browse files

실험버전 업데이트 알림에 별도로 표시

  • Loading branch information...
youknowone committed Jun 13, 2019
1 parent dc00480 commit c8f2239a32157b64505dc323539671e4121517d2
Showing with 14 additions and 7 deletions.
  1. +1 −1 GureumTests/GureumTests.swift
  2. +1 −0 GureumTests/MockInputClient.m
  3. +12 −6 OSX/UpdateManager.swift
@@ -68,7 +68,7 @@ class GureumTests: XCTestCase {
XCTFail()
return
}
let versionInfo = UpdateManager.VersionInfo(data: versionInfoJSON)
let versionInfo = UpdateManager.VersionInfo(data: versionInfoJSON, experimental: true)
UpdateManager.shared.notifyUpdate(info: versionInfo)
XCTAssertEqual("최신 버전: 1.10.0 현재 버전: \(UpdateManager.bundleVersion ?? "-")\nMojave 대응을 포함한 대형 업데이트", lastNotification.informativeText)
XCTAssertEqual(["url": "https://github.com/gureum/gureum/releases/tag/1.10.0"], lastNotification.userInfo as! [String: String])
@@ -27,6 +27,7 @@ - (NSString *)selectedString {
}

- (void)insertText:(id)string replacementRange:(NSRange)replacementRange {
// NSAssert(replacementRange.location == NSNotFound || replacementRange.length != 0, @"-");
[super insertText:string replacementRange:replacementRange];
}

@@ -16,8 +16,10 @@ class UpdateManager {
class VersionInfo {
let current: String? = UpdateManager.bundleVersion
let data: [String: String]
init(data: [String: String]) {
let experimental: Bool
init(data: [String: String], experimental: Bool) {
self.data = data
self.experimental = experimental
}

var recent: String? {
@@ -36,7 +38,7 @@ class UpdateManager {
}
}

func fetchVersionInfo(from url: URL) -> VersionInfo? {
func fetchVersionInfo(from url: URL, experimental: Bool) -> VersionInfo? {
var request = URLRequest(url: url)
request.timeoutInterval = 0.5
request.cachePolicy = .reloadIgnoringCacheData
@@ -49,17 +51,17 @@ class UpdateManager {
guard let info = try? JSONSerialization.jsonObject(with: data as Data) as? [String: String] else {
return nil
}
return VersionInfo(data: info)
return VersionInfo(data: info, experimental: experimental)
}

func fetchOfficialVersionInfo() -> VersionInfo? {
let url = URL(string: "http://gureum.io/version.json")!
return fetchVersionInfo(from: url)
return fetchVersionInfo(from: url, experimental: false)
}

func fetchExperimentalVersionInfo() -> VersionInfo? {
let url = URL(string: "http://gureum.io/version-experimental.json")!
return fetchVersionInfo(from: url)
return fetchVersionInfo(from: url, experimental: true)
}

func fetchAutoUpdateVersionInfo() -> VersionInfo? {
@@ -75,7 +77,11 @@ class UpdateManager {

func notifyUpdate(info: VersionInfo) {
let notification = NSUserNotification()
notification.title = "구름 입력기 업데이트 알림"
var title = "구름 입력기 업데이트 알림"
if info.experimental {
title += " (실험 버전)"
}
notification.title = title
notification.hasActionButton = true
notification.hasReplyButton = false
notification.actionButtonTitle = "업데이트"

0 comments on commit c8f2239

Please sign in to comment.
You can’t perform that action at this time.