Skip to content

Commit

Permalink
Added dedicated remove(presentedVersion:) API to WhatsNewVersionStore…
Browse files Browse the repository at this point in the history
… implementations

#64
  • Loading branch information
SvenTiigi committed Mar 2, 2023
1 parent 641b2f5 commit fbff3db
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Sources/Store/InMemoryWhatsNewVersionStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class InMemoryWhatsNewVersionStore {
// MARK: Properties

/// The Versions
public var versions: [WhatsNew.Version]
public var versions: Set<WhatsNew.Version>

// MARK: Initializer

Expand All @@ -33,7 +33,7 @@ extension InMemoryWhatsNewVersionStore: WriteableWhatsNewVersionStore {
public func save(
presentedVersion version: WhatsNew.Version
) {
self.versions.append(version)
self.versions.insert(version)
}

}
Expand All @@ -44,7 +44,21 @@ extension InMemoryWhatsNewVersionStore: ReadableWhatsNewVersionStore {

/// The WhatsNew Versions that have been already been presented
public var presentedVersions: [WhatsNew.Version] {
self.versions
.init(self.versions)
}

}

// MARK: - Remove

public extension InMemoryWhatsNewVersionStore {

/// Remove presented WhatsNew Version
/// - Parameter version: The presented WhatsNew Version that should be removed
func remove(
presentedVersion version: WhatsNew.Version
) {
self.versions.remove(version)
}

}
Expand Down
15 changes: 15 additions & 0 deletions Sources/Store/NSUbiquitousKeyValueWhatsNewVersionStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ extension NSUbiquitousKeyValueWhatsNewVersionStore: ReadableWhatsNewVersionStore

}

// MARK: - Remove

public extension NSUbiquitousKeyValueWhatsNewVersionStore {

/// Remove presented WhatsNew Version
/// - Parameter version: The presented WhatsNew Version that should be removed
func remove(
presentedVersion version: WhatsNew.Version
) {
self.ubiquitousKeyValueStore
.removeObject(forKey: version.key)
}

}

// MARK: - Remove all

public extension NSUbiquitousKeyValueWhatsNewVersionStore {
Expand Down
15 changes: 15 additions & 0 deletions Sources/Store/UserDefaultsWhatsNewVersionStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ extension UserDefaultsWhatsNewVersionStore: ReadableWhatsNewVersionStore {

}

// MARK: - Remove

public extension UserDefaultsWhatsNewVersionStore {

/// Remove presented WhatsNew Version
/// - Parameter version: The presented WhatsNew Version that should be removed
func remove(
presentedVersion version: WhatsNew.Version
) {
self.userDefaults
.removeObject(forKey: version.key)
}

}

// MARK: - Remove all

public extension UserDefaultsWhatsNewVersionStore {
Expand Down

0 comments on commit fbff3db

Please sign in to comment.