Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Integrated GitHub Actions support (kinda) #2828

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/Bookmark/BookmarkCloudMigrator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class BookmarkCloudMigrator {
init(username: String, oldBookmarks: [Bookmark], client: BookmarkCloudMigratorClient) {
self.bookmarks = oldBookmarks.compactMap {
switch $0.type {
case .commit, .release, .securityVulnerability: return nil
case .commit, .release, .securityVulnerability, .ci_activity: return nil
case .issue, .pullRequest:
return .issueOrPullRequest(owner: $0.owner, name: $0.name, number: $0.number)
case .repo:
Expand Down
3 changes: 1 addition & 2 deletions Classes/Notifications/NewFeaturesController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ final class NewFeaturesController {
}
}
}

// fetches for the latest changes
func fetch(success: @escaping () -> Void) {
guard let url = fetchURL,
(testing == true || hasFetchedLatest == false)
else { return }
hasFetchedLatest = true

let task = session.dataTask(with: url) { (data, response, _) in
if let response = response as? HTTPURLResponse,
response.statusCode == 200,
Expand Down
23 changes: 14 additions & 9 deletions Classes/Notifications/Notification+NotificationViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ func CreateNotificationViewModels(
var models = [NotificationViewModel]()

for notification in v3notifications {
guard let type = NotificationType(rawValue: notification.subject.type.rawValue),
let identifier = notification.subject.identifier
guard let type = NotificationType(rawValue: notification.subject.type.rawValue)
else { continue }

let number: NotificationViewModel.Number
switch identifier {
case .hash(let h): number = .hash(h)
case .number(let n): number = .number(n)
case .release(let r): number = .release(r)

if notification.subject.identifier != nil {
guard let identifier = notification.subject.identifier
else {continue}
switch identifier {
case .hash(let h): number = .hash(h)
case .number(let n): number = .number(n)
case .release(let r): number = .release(r)
}
} else {
number = .number(1)
}

models.append(NotificationViewModel(
v3id: notification.id,
repo: notification.repository.name,
Expand All @@ -47,8 +51,9 @@ func CreateNotificationViewModels(
branch: "master",
issuesEnabled: true
))

}

DispatchQueue.main.async {
completion(models)
}
Expand Down
7 changes: 4 additions & 3 deletions Classes/Notifications/NotificationCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ final class NotificationCell: SelectableCell, CAAnimationDelegate {
titleAttributes[.font] = Styles.Text.secondary.preferredFont
switch model.number {
case .number(let number):
guard model.type != .securityVulnerability else { break }
guard model.type != .securityVulnerability || model.type != .ci_activity else { break }
title.append(NSAttributedString(string: "#\(number)", attributes: titleAttributes))
default: break
}
Expand All @@ -184,10 +184,11 @@ final class NotificationCell: SelectableCell, CAAnimationDelegate {
case .open: tintColor = Styles.Colors.Green.medium.color
case .pending: tintColor = Styles.Colors.Blue.medium.color
}
iconImageView.tintColor = tintColor

iconImageView.tintColor = tintColor

iconImageView.image = model.type.icon(merged: model.state == .merged)?
.withRenderingMode(.alwaysTemplate)

let hasComments = model.comments > 0
commentButton.alpha = hasComments ? 1 : 0.3
commentButton.setTitle(hasComments ? model.comments.abbreviated : "", for: .normal)
Expand Down
2 changes: 2 additions & 0 deletions Classes/Notifications/NotificationModelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ final class NotificationModelController {
}
} else {
githubClient.client.send(V3NotificationRequest(all: all, page: page)) { [weak self] result in

switch result {
case .success(let response):
self?.handle(
Expand Down Expand Up @@ -244,6 +245,7 @@ final class NotificationModelController {
case .created: mapped = .created
}

// Seems important
githubClient.client.send(V3IssuesRequest(filter: mapped, page: page), completion: { result in
// iterate result data, convert to InboxDashboardModel
switch result {
Expand Down
10 changes: 8 additions & 2 deletions Classes/Notifications/NotificationSectionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,18 @@ final class NotificationSectionController: ListSwiftSectionController<Notificati
}

private func showIssue(model: NotificationViewModel) {
if model.type == .ci_activity {
guard let url = URL(string: "https://github.com/" + model.owner + "/" + model.repo + "/actions" ) else { return }
viewController?.presentSafari(url: url)
} else {
if NotificationModelController.readOnOpen {
modelController.markNotificationRead(id: model.id)
}



BadgeNotifications.clear(for: model)

guard model.type != .securityVulnerability else {
guard model.type != .securityVulnerability || model.type != .ci_activity else {
viewController?.route_push(to: RepositoryViewController(
client: modelController.githubClient,
repo: RepositoryDetails(owner: model.owner, name: model.repo)
Expand All @@ -102,6 +107,7 @@ final class NotificationSectionController: ListSwiftSectionController<Notificati
showRelease(release, model: model)
}
}
}

private func showRelease(_ release: String, model: NotificationViewModel) {
modelController.githubClient.client
Expand Down
1 change: 1 addition & 0 deletions Classes/Notifications/NotificationType+Icon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extension NotificationType {
case .pullRequest: name = "git-pull-request"
case .release: name = "tag"
case .securityVulnerability: name = "alert"
case .ci_activity: name = "actions"
}
return UIImage(named: name)
}
Expand Down
2 changes: 2 additions & 0 deletions Classes/Notifications/NotificationType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum NotificationType: String {
case repo = "Repository"
case release = "Release"
case securityVulnerability = "RepositoryVulnerabilityAlert"
case ci_activity = "CheckSuite"

var localizedString: String {
switch self {
Expand All @@ -25,6 +26,7 @@ enum NotificationType: String {
case .release: return NSLocalizedString("Release", comment: "")
case .pullRequest: return Constants.Strings.pullRequest
case .securityVulnerability: return NSLocalizedString("Security Vulnerability", comment: "")
case .ci_activity: return NSLocalizedString("CI Activity", comment: "")
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/Notifications/NotificationsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ InboxFilterControllerListener {

override func viewDidLoad() {
super.viewDidLoad()

makeBackBarItemEmpty()
resetRightBarItem()

Expand All @@ -62,7 +61,7 @@ InboxFilterControllerListener {
navigationTitle.addTouchEffect()
navigationTitle.titleFont = UIFont.preferredFont(forTextStyle: .headline)
navigationTitle.addTarget(self, action: #selector(onNavigationTitle), for: .touchUpInside)

// @ Fetches for new features
newFeaturesController?.fetch { [weak self] in
self?.update()
}
Expand Down
14 changes: 5 additions & 9 deletions Freetime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2494,7 +2494,7 @@
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.ApplicationGroups.iOS = {
enabled = 1;
enabled = 0;
};
};
};
Expand All @@ -2510,12 +2510,11 @@
};
297AE8331EC0D58A00B44A1F = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 523C4DWBTH;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.ApplicationGroups.iOS = {
enabled = 1;
enabled = 0;
};
com.apple.BackgroundModes = {
enabled = 1;
Expand Down Expand Up @@ -3501,7 +3500,6 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = FreetimeWatch/FreetimeWatch.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
Expand All @@ -3528,7 +3526,6 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = FreetimeWatch/FreetimeWatch.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
Expand All @@ -3555,7 +3552,6 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = FreetimeWatch/FreetimeWatch.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -3772,7 +3768,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 523C4DWBTH;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand Down Expand Up @@ -3815,7 +3811,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 523C4DWBTH;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand Down Expand Up @@ -3945,7 +3941,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 523C4DWBTH;
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand Down
1 change: 1 addition & 0 deletions FreetimeWatch Extension/RepoInboxRowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final class RepoInboxRowController: NSObject {
case .release: imageName = "tag"
case .repo: imageName = "repo"
case .vulnerabilityAlert: imageName = "alert"
case .ci_activity: imageName = "alert"
}
typeImage.setImage(UIImage(named: imageName)?.withRenderingMode(.alwaysTemplate))

Expand Down
7 changes: 1 addition & 6 deletions FreetimeWatch/FreetimeWatch.entitlements
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.whoisryannystrom.freetime</string>
</array>
</dict>
<dict/>
</plist>
1 change: 0 additions & 1 deletion Local Pods/GitHubAPI/GitHubAPI/V3DataResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public struct V3DataResponse<T: Codable>: EntityResponse {

// https://developer.github.com/v3/#schema
decoder.dateDecodingStrategy = .iso8601

self.data = try decoder.decode(T.self, from: input)
self.next = (response?.allHeaderFields["Link"] as? String)?.httpNextPageNumber
}
Expand Down
1 change: 1 addition & 0 deletions Local Pods/GitHubAPI/GitHubAPI/V3Notification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public struct V3Notification: Codable {
case teamMention = "team_mention"
case reviewRequested = "review_requested"
case securityAlert = "security_alert"
case ci_activity = "ci_activity"
}

public let id: String
Expand Down
1 change: 1 addition & 0 deletions Local Pods/GitHubAPI/GitHubAPI/V3NotificationSubject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public struct V3NotificationSubject: Codable {
case release = "Release"
case invitation = "RepositoryInvitation"
case vulnerabilityAlert = "RepositoryVulnerabilityAlert"
case ci_activity = "CheckSuite"
}

public let title: String
Expand Down
22 changes: 22 additions & 0 deletions Resources/Assets.xcassets/actions.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions Resources/Freetime.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
<array/>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.whoisryannystrom.freetime</string>
</array>
</dict>
</plist>