Consolidate sitemap page view models with shared OpenHABCore base#1245
Open
timbms wants to merge 6 commits into
Open
Consolidate sitemap page view models with shared OpenHABCore base#1245timbms wants to merge 6 commits into
timbms wants to merge 6 commits into
Conversation
…e base Introduces SitemapPageViewModelBase (open class, @mainactor, ObservableObject) in OpenHABCore, shared by SitemapPageViewModel (iOS) and UserData (watchOS): - Common published state: currentPage, isLoading, error - runNewHandlingTask: cancels and replaces running tasks; generation guard prevents a superseded task's cleanup from clearing a newer task's slot - runStreamLoop: drives SitemapPageLoader.stream and calls handlePageUpdate; subclasses override handlePageUpdate for platform-specific behaviour - shouldRetryPolling: shared transient-error policy covering URL errors and HTTP 408/429/499/500/502/503/504; static, placed before instance methods - stopHandling: cancels the active task and resets loading state Drops the SitemapPageLoader connectionInfo convenience overload; stream setup is now owned by the base class. Adds SitemapLinkedPage (Hashable, Sendable) to OpenHABCore as the shared navigation value type, replacing the iOS-only LinkedPageNavigation. Carries link, title, and pageId explicitly. pageId is threaded through WidgetLinkedPageSnapshot → LinkedPageRowInput → SitemapLinkedPage so the incremental builder detects pageId-only changes via WidgetRenderKey (linkedPageId field added) and SitemapNavigationView passes the authoritative ID directly to SitemapPageViewModel rather than reconstructing it from the URL. Adds localization entry for "Item '%@' not found" (auto-extracted by Xcode). Tests added in OpenHABCoreTests: - SitemapPageViewModelRetryPolicyTests: parameterized over all transient URL error codes, all retried HTTP status codes, terminal codes, named error cases, and unknown errors - SitemapPageViewModelTaskTests: same-key no-op, different-key replacement, force-restart, slot auto-clear after body returns, generation guard - SitemapRowInputBuilderTests: incremental rebuild detects linkedPageId change Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
… MediaRowView Add missing linkedPageId field to MediaRowInput and wire it through both construction sites so MediaRowView can construct SitemapLinkedPage correctly. Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SitemapPageViewModelBase(open class,@MainActor,ObservableObject) inOpenHABCore, subclassed by bothSitemapPageViewModel(iOS) andUserData(watchOS). Shared state:currentPage,isLoading,error. Shared behaviour:runNewHandlingTask(task lifecycle with generation guard),runStreamLoop(drivesSitemapPageLoader.stream),shouldRetryPolling(transient URL errors + HTTP 408/429/499/500/502/503/504),stopHandling.SitemapPageLoaderconnectionInfoconvenience overload; stream setup is now owned by the base class.SitemapLinkedPage(Hashable,Sendable) toOpenHABCoreas a shared navigation value type, replacing the iOS-onlyLinkedPageNavigation. Carrieslink,title, andpageIdexplicitly.pageIdis threaded throughWidgetLinkedPageSnapshot→LinkedPageRowInput→WidgetRenderKeyso the incremental builder detects page-ID-only changes, andSitemapNavigationViewpasses the authoritative ID directly to the view model rather than reconstructing it from the URL."Item '%@' not found"(auto-extracted by Xcode).Tests
SitemapPageViewModelRetryPolicyTests: parameterized over all transient URL error codes, all retried HTTP status codes, terminal codes, namedOpenAPIServiceErrorcases, and unknown errors.SitemapPageViewModelTaskTests: same-key no-op, different-key replacement, force-restart, slot auto-clear after body returns, generation guard (stale cleanup doesn't clobber a newer task's slot).SitemapRowInputBuilderTests: new case verifies incremental rebuild detects alinkedPageId-only change.Test plan
stopLongPollingon disappear cancels correctly