Per-widget server settings are not read for instance scopes (widgets with configuration parameters)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với WidgetServerSettingsStore.kt và WidgetScope.kt trên Android: xác nhận rằng widgetKey/storageKey khác nhau đối với WidgetScope.Instance, sau đó điều chỉnh lớp cài đặt widget để đọc qua WidgetScope.of(scope.widgetId). Thêm bài test Robolectric từ issue dưới packages/android-client/android/src/test/java/voltra/widget/server/ và chạy lệnh test Gradle đã cho. Sau đó phản chiếu thay đổi trong đường dẫn iOS WidgetWidgetServerSettingsLayer.settings(for:) và kiểm tra các test store hiện có; hoàn tất nghĩa là một instance kế thừa URL, interval, method, headers và body của widget của nó trong khi ETag/status/props vẫn theo từng instance.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 864
- Fork
- 51
- Merge trung bình
- 2 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 10
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của callstackincubator/voltra
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
callstackincubator/voltra#376 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
iOS: first foreground after launch remounts the whole app (isHeadless written into root appProperties)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởplatform:iOS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
callstackincubator/voltra#340 · 1 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
refactor-scout
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
callstackincubator/voltra#308 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
refactor-scout
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
callstackincubator/voltra#307 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement platform:Android
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
callstackincubator/voltra#380 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của callstackincubator/voltra
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
cursor/community-plugins#583 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
afk-ok importer size:S
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
enorm-labs/event-junkie#5404 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Wavvon/Wavvon-clients#493 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
answerLoops/answerLoops#679 ·
Maintainer thường phản hồi trong vòng 1 ngày