Skip to content

Commit 52e45fa

Browse files
committed
fix(registry): fix type safety in getOwnerId
- Added explicit cast for type safety
1 parent f9c3ed5 commit 52e45fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/src/registry/model_registry.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ final modelRegistry = <String, ModelConfig<dynamic>>{
193193
'user': ModelConfig<User>(
194194
fromJson: User.fromJson,
195195
getId: (u) => u.id,
196-
getOwnerId: (u) => u.id, // User is the owner of their profile
196+
getOwnerId: (dynamic item) => (item as User).id as String?, // User is the owner of their profile
197197
getPermission: const ModelActionPermission(
198198
type: RequiredPermissionType.specificPermission,
199199
permission: Permissions.userReadOwned, // User can read their own
@@ -216,7 +216,7 @@ final modelRegistry = <String, ModelConfig<dynamic>>{
216216
'user_app_settings': ModelConfig<UserAppSettings>(
217217
fromJson: UserAppSettings.fromJson,
218218
getId: (s) => s.id,
219-
getOwnerId: (s) => s.id, // User ID is the owner ID
219+
getOwnerId: (dynamic item) => (item as UserAppSettings).id as String?, // User ID is the owner ID
220220
getPermission: const ModelActionPermission(
221221
type: RequiredPermissionType.specificPermission,
222222
permission: Permissions.appSettingsReadOwned,
@@ -242,7 +242,7 @@ final modelRegistry = <String, ModelConfig<dynamic>>{
242242
'user_content_preferences': ModelConfig<UserContentPreferences>(
243243
fromJson: UserContentPreferences.fromJson,
244244
getId: (p) => p.id,
245-
getOwnerId: (p) => p.id, // User ID is the owner ID
245+
getOwnerId: (dynamic item) => (item as UserContentPreferences).id as String?, // User ID is the owner ID
246246
getPermission: const ModelActionPermission(
247247
type: RequiredPermissionType.specificPermission,
248248
permission: Permissions.userPreferencesReadOwned,

0 commit comments

Comments
 (0)