3 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
Zhigang Fang
4fda478078 Bump version 2017-10-31 11:04:25 +08:00
Zhigang Fang
0f7546836a Make project optional 2017-10-31 11:02:28 +08:00
Zhigang Fang
4f9efc4fd0 Update README.md 2017-10-28 01:43:35 -05:00
3 changed files with 10 additions and 10 deletions

View File

@@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>5</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>

View File

@@ -31,8 +31,8 @@ struct User: Decodable {
let id: Int64
let fullname: String
let projects: [Project]
let time_entries: [TimeEntry]
let projects: [Project]?
let time_entries: [TimeEntry]?
}
@@ -123,8 +123,8 @@ class TogglViewModel {
var completions: Driver<[String]> {
return user.asDriver().map({ user -> [String] in
guard let user = user else { return [] }
let projects = user.projects.map({"#\($0.name)"})
let entries = user.time_entries.sorted(by: {$0.start > $1.start}).flatMap({$0.description})
let projects = user.projects?.map({"#\($0.name)"}) ?? []
let entries = user.time_entries?.sorted(by: {$0.start > $1.start}).flatMap({$0.description}) ?? []
return Array(NSOrderedSet(array: projects + entries)).flatMap({$0 as? String})
}).flatMapLatest({[weak self] (completion:[String]) -> Driver<[String]> in
guard let input = self?.input else { return .just(completion) }
@@ -172,16 +172,16 @@ class TogglViewModel {
})
}
return Driver<TimeEntry?>.just(nil)
}).debug().drive(current).disposed(by: self.disposeBag)
}).drive(current).disposed(by: self.disposeBag)
token.asDriver().flatMapLatest({[weak self] token -> Driver<User?> in
if let token = token {
return self?.current.asDriver().flatMapLatest({ _ in
Endpoint<User>.me.request(with: token).map(Optional.some).asDriver(onErrorJustReturn: nil)
Endpoint<User>.me.request(with: token).map(Optional.some).debug("Test").asDriver(onErrorJustReturn: nil)
}) ?? .just(nil)
}
return Driver<User?>.just(nil)
}).debug().drive(user).disposed(by: self.disposeBag)
}).drive(user).disposed(by: self.disposeBag)
NSWorkspace.shared.notificationCenter
.rx.notification(NSWorkspace.screensDidSleepNotification)
@@ -214,7 +214,7 @@ class TogglViewModel {
func startTimer() {
let inputValue = input.value
if let projectName = inputValue.hashKey {
if let existingProject = self.user.value?.projects.first(where: {
if let existingProject = self.user.value?.projects?.first(where: {
$0.name.lowercased() == projectName.lowercased()
}) {
self.startTimer(input: inputValue, projectId: existingProject.id)

View File

@@ -9,7 +9,7 @@ First you need to obtain your API token from:
https://www.toggl.com/app/profile
Download this app from https://github.com/zhigang1992/TogglBar/releases
Download this app from https://github.com/zhigang1992/InTime/releases/tag/1.0.0
And you're all set.