Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import Supabase
import UIKit

/// Dependency injection container for the application
class DIContainer {
Expand Down Expand Up @@ -59,4 +60,30 @@ class DIContainer {
renderers.forEach { registry.register(renderer: $0) }
return registry
}()

// MARK: - Store

lazy var store: DefaultStore = {
let appID = Bundle.main.bundleIdentifier ?? "render-ios-playground"
return DefaultStore(appID: appID)
}()

func scenarioStore(id: String) -> KeyValueStore {
return store.named(.scenarioSession(id: id))
}

func ensureScenarioVersionDropIfNeeded(id: String, version: String) {
let defaults = UserDefaults.standard
let key = "\(Bundle.main.bundleIdentifier ?? appBundleIDFallback).store.scenario.major.\(id)"
let currentMajor = SemanticVersion(string: version)?.major ?? 0
let previousMajor = defaults.integer(forKey: key)
if previousMajor != 0 && previousMajor != currentMajor {
// Drop scenario session data on major change
let kv = scenarioStore(id: id)
kv.replaceAll(with: [:])
}
defaults.set(currentMajor, forKey: key)
}

private var appBundleIDFallback: String { "render-ios-playground" }
}
Loading