Per-widget server settings are not read for instance scopes (widgets with configuration parameters)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
Android では WidgetServerSettingsStore.kt と WidgetScope.kt から始めます。widgetKey/storageKey が WidgetScope.Instance で異なることを確認し、その後 widget settings layer が WidgetScope.of(scope.widgetId) で読み取るように調整します。issue にある Robolectric テストを packages/android-client/android/src/test/java/voltra/widget/server/ 配下に追加し、示された Gradle テストコマンドを実行します。次に iOS の WidgetWidgetServerSettingsLayer.settings(for:) パスに変更をミラーし、既存の store テストを確認します。完了とは、インスタンスが自身の widget の URL、interval、method、headers、body を継承し、ETag/status/props はインスタンスごとに残ることを意味します。
索引モデルが issue の本文から書いたものです。
説明
Follow-up to #363. Found while reading the instance-scope code; confirmed on Android with a unit test, iOS from reading the code.
What happens
On main (b4b6e74), a widget that has configuration parameters resolves to WidgetScope.Instance. The per-widget settings layer then looks for settings under the instance's storage key (<widgetId>#<key>), but setWidgetServerUpdate with a widget id writes them under the widget id. So an instance does not see the URL, interval, method, headers or body set for its widget, and falls back to the global or config layers.
Expected
What WidgetScope and ADR 0007 say: "the settings layers keep resolving by widget id, so an instance inherits the widget's URL, interval, method, headers and body."
- https://github.com/callstackincubator/voltra/blob/b4b6e74c8d4582310351a379c3a53d53d90e29ec/packages/android-client/android/src/main/java/voltra/widget/server/WidgetScope.kt#L9-L11
- https://github.com/callstackincubator/voltra/blob/b4b6e74c8d4582310351a379c3a53d53d90e29ec/docs/adr/0007-per-instance-server-fetches.md#L130-L134
Cause
Android: the widget layer reads store.widgetKey(scope), and widgetKey uses scope.storageKey, which for an instance is "$widgetId#$key".
- https://github.com/callstackincubator/voltra/blob/b4b6e74c8d4582310351a379c3a53d53d90e29ec/packages/android-client/android/src/main/java/voltra/widget/server/WidgetServerSettingsStore.kt#L140
- https://github.com/callstackincubator/voltra/blob/b4b6e74c8d4582310351a379c3a53d53d90e29ec/packages/android-client/android/src/main/java/voltra/widget/server/WidgetServerSettingsStore.kt#L109
- https://github.com/callstackincubator/voltra/blob/b4b6e74c8d4582310351a379c3a53d53d90e29ec/packages/android-client/android/src/main/java/voltra/widget/server/WidgetScope.kt#L35-L41
iOS has the same shape: WidgetWidgetServerSettingsLayer calls WidgetServerSettingsStore.settings(scope:), whose keychain account is built from scope.storageKey.
- https://github.com/callstackincubator/voltra/blob/b4b6e74c8d4582310351a379c3a53d53d90e29ec/packages/ios-client/ios/shared/WidgetServer/WidgetServerSettingsStore.swift#L143-L145
- https://github.com/callstackincubator/voltra/blob/b4b6e74c8d4582310351a379c3a53d53d90e29ec/packages/ios-client/ios/shared/WidgetServer/WidgetServerSettingsStore.swift#L66
Repro (Android, Robolectric)
@RunWith(RobolectricTestRunner::class)
class WidgetSettingsInstanceScopeTest {
private val url = "https://example.com/per-widget"
@Test
fun instanceScopeInheritsThePerWidgetSettingOfItsWidget() = runTest {
val store = WidgetServerSettingsStore(RuntimeEnvironment.getApplication())
store.set(WidgetServerUpdateSettings(url = url), WidgetScope.of("weather"))
val resolved = WidgetWidgetServerSettingsLayer(store).settings(WidgetScope.Instance("weather", "k1"))
assertEquals(url, resolved?.url)
}
}
Placed in packages/android-client/android/src/test/java/voltra/widget/server/ and run with ./example/android/gradlew -p example/android :use-voltra_android-client:testDebugUnitTest --tests voltra.widget.server.WidgetSettingsInstanceScopeTest:
java.lang.AssertionError: expected:<https://example.com/per-widget> but was:<null>
The same test with WidgetScope.of("weather") on the read side passes.
Possible fix
Have the widget layer read by widget id on both platforms, e.g. on Android store.read(store.widgetKey(WidgetScope.of(scope.widgetId))) in WidgetWidgetServerSettingsLayer, and WidgetServerSettingsStore.settings(scope: .widget(id: scope.widgetId)) in WidgetWidgetServerSettingsLayer.settings(for:) on iOS. The ETag, status and props stores should keep using storageKey, since those are meant to be per instance.
Library version: 2.6.1 (main at b4b6e74). Not tied to a React Native, React or Expo version.
- 主要言語
- TypeScript
- スター
- 864
- フォーク
- 51
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 10
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
callstackincubator/voltra のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
callstackincubator/voltra#376 ·
メンテナーはふだん 1 日以内に返信
-
iOS: first foreground after launch remounts the whole app (isHeadless written into root appProperties)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンplatform:iOS
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
callstackincubator/voltra#340 · コメント 1 件 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
refactor-scout
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
callstackincubator/voltra#308 ·
メンテナーはふだん 1 日以内に返信
-
refactor-scout
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
callstackincubator/voltra#307 ·
メンテナーはふだん 1 日以内に返信
-
enhancement platform:Android
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
callstackincubator/voltra#380 ·
メンテナーはふだん 1 日以内に返信
callstackincubator/voltra の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
cursor/community-plugins#583 ·
メンテナーはふだん 1 日以内に返信
-
afk-ok importer size:S
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
enorm-labs/event-junkie#5404 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Wavvon/Wavvon-clients#493 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
answerLoops/answerLoops#679 ·
メンテナーはふだん 1 日以内に返信