Skip to content

Commit

Permalink
Merge pull request #233 from wakatime/feature/linear
Browse files Browse the repository at this point in the history
Add support for Linear
  • Loading branch information
alanhamlett authored Mar 20, 2024
2 parents a6ec69b + c126c7d commit 56e58cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
18 changes: 18 additions & 0 deletions WakaTime/Extensions/AXUIElementExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ extension AXUIElement {
// swiftlint:enable force_cast
}

var nextSibling: AXUIElement? {
guard let parentChildren = self.parent?.children, let currentIndex = parentChildren.firstIndex(of: self) else { return nil }
let nextIndex = currentIndex + 1
guard parentChildren.indices.contains(nextIndex) else { return nil }
return parentChildren[nextIndex]
}

var previousSibling: AXUIElement? {
guard let parentChildren = self.parent?.children, let currentIndex = parentChildren.firstIndex(of: self) else { return nil }
let previousIndex = currentIndex - 1
guard parentChildren.indices.contains(previousIndex) else { return nil }
return parentChildren[previousIndex]
}

var id: String? {
guard let ref = getValue(for: kAXIdentifierAttribute) else { return nil }
// swiftlint:disable force_cast
Expand Down Expand Up @@ -72,6 +86,10 @@ extension AXUIElement {
case .firefox:
let addressField = findAddressField()
address = addressField?.value
case .linear:
let projectLabel = firstDescendantWhere { $0.value == "Project" }
let projectButton = projectLabel?.nextSibling?.firstDescendantWhere { $0.role == kAXButtonRole }
return projectButton?.rawTitle
case .safari:
let addressField = elementById(identifier: "WEB_BROWSER_ADDRESS_AND_SEARCH_FIELD")
address = addressField?.value
Expand Down
4 changes: 1 addition & 3 deletions WakaTime/Extensions/NSRunningApplicationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ enum MonitoredApp: String, CaseIterable {
]

// list apps which we aren't yet able to track, so they're hidden from the Monitored Apps menu
static let unsupportedAppIds = [
MonitoredApp.linear.rawValue,
]
static let unsupportedAppIds = [String]()
}

extension NSRunningApplication {
Expand Down
1 change: 1 addition & 0 deletions WakaTime/Helpers/MonitoringManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class MonitoringManager {
case .linear:
return HeartbeatData(
entity: title,
project: project,
category: .planning)
case .notes:
if activeWindow.rawTitle == "Notes" {
Expand Down

0 comments on commit 56e58cf

Please sign in to comment.