Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/unsupported-url
Browse files Browse the repository at this point in the history
  • Loading branch information
krugerk authored Jan 3, 2025
2 parents 8348e38 + d3c955d commit c1b0e30
Show file tree
Hide file tree
Showing 52 changed files with 84 additions and 80 deletions.
2 changes: 1 addition & 1 deletion BeeKit/BeeKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeKit
//
// Created by Andrew Brett on 5/19/21.
// Copyright © 2021 APB. All rights reserved.
// Copyright 2021 APB. All rights reserved.
//

#import <Foundation/Foundation.h>
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/Config.swift.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andrew Brett on 2/20/20.
// Copyright © 2020 APB. All rights reserved.
// Copyright 2020 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/DateUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Theo Spears on 1/27/23.
// Copyright © 2023 APB. All rights reserved.
// Copyright 2023 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/HeathKit/HealthKitConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 3/25/17.
// Copyright © 2017 APB. All rights reserved.
// Copyright 2017 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/HeathKit/HealthKitError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Theo Spears on 11/5/22.
// Copyright © 2022 APB. All rights reserved.
// Copyright 2022 APB. All rights reserved.
//

import Foundation
Expand Down
30 changes: 16 additions & 14 deletions BeeKit/Managers/CurrentUserManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 4/26/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import CoreData
Expand All @@ -17,14 +17,16 @@ import SwiftyJSON
public actor CurrentUserManager {
let logger = Logger(subsystem: "com.beeminder.beeminder", category: "CurrentUserManager")

public static let signedInNotificationName = "com.beeminder.signedInNotification"
public static let willSignOutNotificationName = "com.beeminder.willSignOutNotification"
public static let failedSignInNotificationName = "com.beeminder.failedSignInNotification"
public static let signedOutNotificationName = "com.beeminder.signedOutNotification"
public static let resetNotificationName = "com.beeminder.resetNotification"
public static let willResetNotificationName = "com.beeminder.willResetNotification"
public static let healthKitMetricRemovedNotificationName = "com.beeminder.healthKitMetricRemovedNotification"

public enum NotificationName {
public static let signedIn = NSNotification.Name(rawValue: "com.beeminder.signedInNotification")
public static let willSignOut = NSNotification.Name(rawValue: "com.beeminder.willSignOutNotification")
public static let failedSignIn = NSNotification.Name(rawValue: "com.beeminder.failedSignInNotification")
public static let signedOut = NSNotification.Name(rawValue: "com.beeminder.signedOutNotification")
public static let reset = NSNotification.Name(rawValue: "com.beeminder.resetNotification")
public static let willReset = NSNotification.Name(rawValue: "com.beeminder.willResetNotification")
public static let healthKitMetricRemoved = NSNotification.Name(rawValue: "com.beeminder.healthKitMetricRemovedNotification")
}

fileprivate let beemiosSecret = "C0QBFPWqDykIgE6RyQ2OJJDxGxGXuVA2CNqcJM185oOOl4EQTjmpiKgcwjki"

internal static let accessTokenKey = "access_token"
Expand Down Expand Up @@ -165,28 +167,28 @@ public actor CurrentUserManager {
self.setAccessToken(responseJSON[CurrentUserManager.accessTokenKey].string!)

await Task { @MainActor in
NotificationCenter.default.post(name: Notification.Name(rawValue: CurrentUserManager.signedInNotificationName), object: self)
NotificationCenter.default.post(name: CurrentUserManager.NotificationName.signedIn, object: self)
}.value
}

func handleFailedSignin(_ responseError: Error, errorMessage : String?) async throws {
await Task { @MainActor in
NotificationCenter.default.post(name: Notification.Name(rawValue: CurrentUserManager.failedSignInNotificationName), object: self, userInfo: ["error" : responseError])
NotificationCenter.default.post(name: CurrentUserManager.NotificationName.failedSignIn, object: self, userInfo: ["error" : responseError])
}.value
try await self.signOut()
}

public func signOut() async throws {
await Task { @MainActor in
NotificationCenter.default.post(name: Notification.Name(rawValue: CurrentUserManager.willSignOutNotificationName), object: self)
NotificationCenter.default.post(name: CurrentUserManager.NotificationName.willSignOut, object: self)
}.value

try deleteUser()

keychain.delete(CurrentUserManager.accessTokenKey)

await Task { @MainActor in
NotificationCenter.default.post(name: Notification.Name(rawValue: CurrentUserManager.signedOutNotificationName), object: self)
NotificationCenter.default.post(name: CurrentUserManager.NotificationName.signedOut, object: self)
}.value
}
}
}
14 changes: 8 additions & 6 deletions BeeKit/Managers/GoalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Theo Spears on 2/7/23.
// Copyright © 2023 APB. All rights reserved.
// Copyright 2023 APB. All rights reserved.
//

import Foundation
Expand All @@ -18,9 +18,11 @@ import OrderedCollections
public actor GoalManager {
private let logger = Logger(subsystem: "com.beeminder.beeminder", category: "GoalManager")

/// A notification that is triggered any time the data for one or more goals is updated
public static let goalsUpdatedNotificationName = "com.beeminder.goalsUpdatedNotification"

public enum NotificationName {
/// A notification that is triggered any time the data for one or more goals is updated
public static let goalsUpdated = NSNotification.Name(rawValue: "com.beeminder.goalsUpdatedNotification")
}

private let requestManager: RequestManager
private nonisolated let currentUserManager: CurrentUserManager

Expand All @@ -42,7 +44,7 @@ public actor GoalManager {
// 2) Other methods may be called with the actor executor, so it is no longer safe for the constructor to
// access class properties.

NotificationCenter.default.addObserver(self, selector: #selector(self.onSignedOutNotification), name: NSNotification.Name(rawValue: CurrentUserManager.signedOutNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.onSignedOutNotification), name: CurrentUserManager.NotificationName.signedOut, object: nil)
}

/// Return the state of goals the last time they were fetched from the server. This could have been an arbitrarily long time ago.
Expand Down Expand Up @@ -132,7 +134,7 @@ public actor GoalManager {
// Notify all listeners of the update
await Task { @MainActor in
modelContainer.viewContext.refreshAllObjects()
NotificationCenter.default.post(name: Notification.Name(rawValue: GoalManager.goalsUpdatedNotificationName), object: self)
NotificationCenter.default.post(name: GoalManager.NotificationName.goalsUpdated, object: self)
}.value
}

Expand Down
2 changes: 1 addition & 1 deletion BeeKit/Managers/HealthStoreManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 11/28/17.
// Copyright © 2017 APB. All rights reserved.
// Copyright 2017 APB. All rights reserved.
//

import CoreData
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/Managers/RequestManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 5/10/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/Managers/SignedRequestManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 11/30/17.
// Copyright © 2017 APB. All rights reserved.
// Copyright 2017 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/Managers/VersionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andrew Brett on 3/19/20.
// Copyright © 2020 APB. All rights reserved.
// Copyright 2020 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/ServiceLocator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Theo Spears on 2/7/23.
// Copyright © 2023 APB. All rights reserved.
// Copyright 2023 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/UI/BSButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 4/27/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/UI/BSLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 4/26/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/UI/BSTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 11/22/16.
// Copyright © 2016 APB. All rights reserved.
// Copyright 2016 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/UI/UIColorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 4/26/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/UI/UIFontExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 11/7/15.
// Copyright © 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKit/Util/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 5/15/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeKitTests/BeeKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeKitTests
//
// Created by Andrew Brett on 5/19/21.
// Copyright © 2021 APB. All rights reserved.
// Copyright 2021 APB. All rights reserved.
//

import XCTest
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/AddDataIntentHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andrew Brett on 3/28/21.
// Copyright © 2021 APB. All rights reserved.
// Copyright 2021 APB. All rights reserved.
//

import Foundation
Expand Down
6 changes: 3 additions & 3 deletions BeeSwift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 4/19/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import CoreSpotlight
Expand Down Expand Up @@ -41,8 +41,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD

NetworkActivityIndicatorManager.shared.isEnabled = true

NotificationCenter.default.addObserver(self, selector: #selector(self.handleGoalsUpdated), name: NSNotification.Name(rawValue: GoalManager.goalsUpdatedNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleUserSignedOut), name: NSNotification.Name(rawValue: CurrentUserManager.signedOutNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleGoalsUpdated), name: GoalManager.NotificationName.goalsUpdated, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleUserSignedOut), name: CurrentUserManager.NotificationName.signedOut, object: nil)

backgroundUpdates.startUpdatingRegularlyInBackground()

Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/BeeSwift-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 4/19/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

#import <Foundation/Foundation.h>
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/Components/DatapointTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Theo Spears on 11/27/22.
// Copyright © 2022 APB. All rights reserved.
// Copyright 2022 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/Components/DatapointValueAccessory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Theo Spears on 11/19/22.
// Copyright © 2022 APB. All rights reserved.
// Copyright 2022 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/Components/DatapointsTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 5/16/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/Components/GoalImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class GoalImageView : UIView {
beeLemniscateView.isHidden = true

NotificationCenter.default.addObserver(
forName: NSNotification.Name(rawValue: GoalManager.goalsUpdatedNotificationName),
forName: GoalManager.NotificationName.goalsUpdated,
object: nil,
queue: OperationQueue.main
) { [weak self] _ in
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/Config.sample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 11/29/17.
// Copyright © 2017 APB. All rights reserved.
// Copyright 2017 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/DatapointTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 5/12/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/EditDatapointViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 8/8/18.
// Copyright © 2018 APB. All rights reserved.
// Copyright 2018 APB. All rights reserved.
//

import UIKit
Expand Down
2 changes: 1 addition & 1 deletion BeeSwift/Gallery/ChooseGoalSortViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// BeeSwift
//
// Created by Andy Brett on 12/21/17.
// Copyright © 2017 APB. All rights reserved.
// Copyright 2017 APB. All rights reserved.
//

import UIKit
Expand Down
8 changes: 4 additions & 4 deletions BeeSwift/Gallery/GalleryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BeeSwift
//
// Created by Andy Brett on 4/19/15.
// Copyright (c) 2015 APB. All rights reserved.
// Copyright 2015 APB. All rights reserved.
//

import UIKit
Expand Down Expand Up @@ -65,10 +65,10 @@ class GalleryViewController: UIViewController, UICollectionViewDelegateFlowLayou
override func viewDidLoad() {
super.viewDidLoad()

NotificationCenter.default.addObserver(self, selector: #selector(self.handleSignIn), name: NSNotification.Name(rawValue: CurrentUserManager.signedInNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleSignOut), name: NSNotification.Name(rawValue: CurrentUserManager.signedOutNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleSignIn), name: CurrentUserManager.NotificationName.signedIn, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleSignOut), name: CurrentUserManager.NotificationName.signedOut, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.openGoalFromNotification(_:)), name: NSNotification.Name(rawValue: "openGoal"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleGoalsFetchedNotification), name: NSNotification.Name(rawValue: GoalManager.goalsUpdatedNotificationName), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleGoalsFetchedNotification), name: GoalManager.NotificationName.goalsUpdated, object: nil)

self.view.addSubview(stackView)
stackView.axis = .vertical
Expand Down
Loading

0 comments on commit c1b0e30

Please sign in to comment.