mirror of
https://github.com/zhigang1992/InTime.git
synced 2026-04-23 18:50:03 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fda478078 | ||
|
|
0f7546836a | ||
|
|
4f9efc4fd0 |
@@ -19,7 +19,7 @@
|
|||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>2</string>
|
<string>5</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.productivity</string>
|
<string>public.app-category.productivity</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ struct User: Decodable {
|
|||||||
|
|
||||||
let id: Int64
|
let id: Int64
|
||||||
let fullname: String
|
let fullname: String
|
||||||
let projects: [Project]
|
let projects: [Project]?
|
||||||
let time_entries: [TimeEntry]
|
let time_entries: [TimeEntry]?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +123,8 @@ class TogglViewModel {
|
|||||||
var completions: Driver<[String]> {
|
var completions: Driver<[String]> {
|
||||||
return user.asDriver().map({ user -> [String] in
|
return user.asDriver().map({ user -> [String] in
|
||||||
guard let user = user else { return [] }
|
guard let user = user else { return [] }
|
||||||
let projects = user.projects.map({"#\($0.name)"})
|
let projects = user.projects?.map({"#\($0.name)"}) ?? []
|
||||||
let entries = user.time_entries.sorted(by: {$0.start > $1.start}).flatMap({$0.description})
|
let entries = user.time_entries?.sorted(by: {$0.start > $1.start}).flatMap({$0.description}) ?? []
|
||||||
return Array(NSOrderedSet(array: projects + entries)).flatMap({$0 as? String})
|
return Array(NSOrderedSet(array: projects + entries)).flatMap({$0 as? String})
|
||||||
}).flatMapLatest({[weak self] (completion:[String]) -> Driver<[String]> in
|
}).flatMapLatest({[weak self] (completion:[String]) -> Driver<[String]> in
|
||||||
guard let input = self?.input else { return .just(completion) }
|
guard let input = self?.input else { return .just(completion) }
|
||||||
@@ -172,16 +172,16 @@ class TogglViewModel {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
return Driver<TimeEntry?>.just(nil)
|
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
|
token.asDriver().flatMapLatest({[weak self] token -> Driver<User?> in
|
||||||
if let token = token {
|
if let token = token {
|
||||||
return self?.current.asDriver().flatMapLatest({ _ in
|
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)
|
}) ?? .just(nil)
|
||||||
}
|
}
|
||||||
return Driver<User?>.just(nil)
|
return Driver<User?>.just(nil)
|
||||||
}).debug().drive(user).disposed(by: self.disposeBag)
|
}).drive(user).disposed(by: self.disposeBag)
|
||||||
|
|
||||||
NSWorkspace.shared.notificationCenter
|
NSWorkspace.shared.notificationCenter
|
||||||
.rx.notification(NSWorkspace.screensDidSleepNotification)
|
.rx.notification(NSWorkspace.screensDidSleepNotification)
|
||||||
@@ -214,7 +214,7 @@ class TogglViewModel {
|
|||||||
func startTimer() {
|
func startTimer() {
|
||||||
let inputValue = input.value
|
let inputValue = input.value
|
||||||
if let projectName = inputValue.hashKey {
|
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()
|
$0.name.lowercased() == projectName.lowercased()
|
||||||
}) {
|
}) {
|
||||||
self.startTimer(input: inputValue, projectId: existingProject.id)
|
self.startTimer(input: inputValue, projectId: existingProject.id)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ First you need to obtain your API token from:
|
|||||||
|
|
||||||
https://www.toggl.com/app/profile
|
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.
|
And you're all set.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user