Skip to content

Commit ece92ee

Browse files
committed
refactor(api): align generic data item route with new models
Replaces all references to 'category' with 'topic' and 'app_config' with 'remote_config' in the item-specific data handler at `/api/v1/data/[id].dart`. This change ensures the GET, PUT, and DELETE operations for individual items correctly use the updated `Topic` and `RemoteConfig` models and their corresponding repositories.
1 parent c8ac366 commit ece92ee

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

routes/api/v1/data/[id].dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ Future<Response> _handleGet(
9999
case 'headline':
100100
final repo = context.read<HtDataRepository<Headline>>();
101101
item = await repo.read(id: id, userId: userIdForRepoCall);
102-
case 'category':
103-
final repo = context.read<HtDataRepository<Category>>();
102+
case 'topic':
103+
final repo = context.read<HtDataRepository<Topic>>();
104104
item = await repo.read(id: id, userId: userIdForRepoCall);
105105
case 'source':
106106
final repo = context.read<HtDataRepository<Source>>();
@@ -117,8 +117,8 @@ Future<Response> _handleGet(
117117
case 'user_content_preferences': // New case for UserContentPreferences
118118
final repo = context.read<HtDataRepository<UserContentPreferences>>();
119119
item = await repo.read(id: id, userId: userIdForRepoCall);
120-
case 'app_config': // New case for AppConfig (read by admin)
121-
final repo = context.read<HtDataRepository<AppConfig>>();
120+
case 'remote_config': // New case for RemoteConfig (read by admin)
121+
final repo = context.read<HtDataRepository<RemoteConfig>>();
122122
item = await repo.read(
123123
id: id,
124124
userId: userIdForRepoCall,
@@ -296,12 +296,12 @@ Future<Response> _handlePut(
296296
userId: userIdForRepoCall,
297297
);
298298
}
299-
case 'category':
299+
case 'topic':
300300
{
301-
final repo = context.read<HtDataRepository<Category>>();
301+
final repo = context.read<HtDataRepository<Topic>>();
302302
updatedItem = await repo.update(
303303
id: id,
304-
item: itemToUpdate as Category,
304+
item: itemToUpdate as Topic,
305305
userId: userIdForRepoCall,
306306
);
307307
}
@@ -350,12 +350,12 @@ Future<Response> _handlePut(
350350
userId: userIdForRepoCall,
351351
);
352352
}
353-
case 'app_config': // New case for AppConfig (update by admin)
353+
case 'remote_config': // New case for RemoteConfig (update by admin)
354354
{
355-
final repo = context.read<HtDataRepository<AppConfig>>();
355+
final repo = context.read<HtDataRepository<RemoteConfig>>();
356356
updatedItem = await repo.update(
357357
id: id,
358-
item: itemToUpdate as AppConfig,
358+
item: itemToUpdate as RemoteConfig,
359359
userId: userIdForRepoCall, // userId should be null for AppConfig
360360
);
361361
}
@@ -474,8 +474,8 @@ Future<Response> _handleDelete(
474474
case 'headline':
475475
final repo = context.read<HtDataRepository<Headline>>();
476476
itemToDelete = await repo.read(id: id, userId: userIdForRepoCall);
477-
case 'category':
478-
final repo = context.read<HtDataRepository<Category>>();
477+
case 'topic':
478+
final repo = context.read<HtDataRepository<Topic>>();
479479
itemToDelete = await repo.read(id: id, userId: userIdForRepoCall);
480480
case 'source':
481481
final repo = context.read<HtDataRepository<Source>>();
@@ -492,8 +492,8 @@ Future<Response> _handleDelete(
492492
case 'user_content_preferences': // New case for UserContentPreferences
493493
final repo = context.read<HtDataRepository<UserContentPreferences>>();
494494
itemToDelete = await repo.read(id: id, userId: userIdForRepoCall);
495-
case 'app_config': // New case for AppConfig (delete by admin)
496-
final repo = context.read<HtDataRepository<AppConfig>>();
495+
case 'remote_config': // New case for RemoteConfig (delete by admin)
496+
final repo = context.read<HtDataRepository<RemoteConfig>>();
497497
itemToDelete = await repo.read(
498498
id: id,
499499
userId: userIdForRepoCall,
@@ -531,8 +531,8 @@ Future<Response> _handleDelete(
531531
id: id,
532532
userId: userIdForRepoCall,
533533
);
534-
case 'category':
535-
await context.read<HtDataRepository<Category>>().delete(
534+
case 'topic':
535+
await context.read<HtDataRepository<Topic>>().delete(
536536
id: id,
537537
userId: userIdForRepoCall,
538538
);
@@ -561,8 +561,8 @@ Future<Response> _handleDelete(
561561
id: id,
562562
userId: userIdForRepoCall,
563563
);
564-
case 'app_config': // New case for AppConfig (delete by admin)
565-
await context.read<HtDataRepository<AppConfig>>().delete(
564+
case 'remote_config': // New case for RemoteConfig (delete by admin)
565+
await context.read<HtDataRepository<RemoteConfig>>().delete(
566566
id: id,
567567
userId: userIdForRepoCall,
568568
); // userId should be null for AppConfig

0 commit comments

Comments
 (0)