distinct type per category (story/poyesh/swot split from news)
This commit is contained in:
parent
527986fdb1
commit
80aa5822d3
|
|
@ -237,28 +237,105 @@ class HomeWidgetRepository {
|
|||
if (localData.link.toString().isEmpty ||
|
||||
localData.link.toString() == "null") {
|
||||
// ---------------- UUID short-circuit ----------------
|
||||
// Content from the new content-service uses UUIDs (e.g. cdaa8830-…).
|
||||
// The legacy routes below assume int IDs, so for any UUID we route
|
||||
// straight to InfographyDetails which knows how to fetch by UUID
|
||||
// from content-service.
|
||||
// Content from the new content-service uses UUIDs. The legacy routes
|
||||
// below assume int IDs and can't be reached for UUID content. Route
|
||||
// by `type` to the matching detail screen, all of which know how to
|
||||
// hydrate from content-service when given `contentUuid`.
|
||||
//
|
||||
// Exception: trend / technology / startup intentionally render in
|
||||
// their dedicated web apps (trend.didvan.app, tech.didvan.app,
|
||||
// startup.didvan.app) — for those types we fall through to the
|
||||
// legacy switch below so the URL is constructed and opened in a
|
||||
// WebView, even when the id is a UUID.
|
||||
// their dedicated webview — those fall through to the legacy switch
|
||||
// below so the URL is constructed and opened in a WebView even when
|
||||
// the id is a UUID.
|
||||
const _webViewTypes = {'trend', 'technology', 'startup'};
|
||||
final _isWebViewType = _webViewTypes.contains(localData.type);
|
||||
if (_isUuid(localData.id) && !_isWebViewType) {
|
||||
if (kDebugMode) {
|
||||
print("UUID detected — routing to InfographyDetails for "
|
||||
"type='${localData.type}' id=${localData.id}");
|
||||
// Per-category routing for new (UUID-based) content. Each branch
|
||||
// sends the user to that category's native detail screen, all of
|
||||
// which can hydrate from content-service via `contentUuid`.
|
||||
//
|
||||
// Categories whose detail screen isn't UUID-aware yet fall through
|
||||
// to InfographyDetails (the generic content reader). When you wire
|
||||
// a new screen, add another case here.
|
||||
final type = localData.type ?? '';
|
||||
switch (type) {
|
||||
// Hard news / story / poyesh / swot all live in the NewsDetails
|
||||
// pager — same UI, different category filter.
|
||||
case 'news':
|
||||
case 'story':
|
||||
case 'poyesh':
|
||||
case 'swot':
|
||||
route = Routes.newsDetails;
|
||||
args = {
|
||||
'contentUuid': localData.id,
|
||||
'args': const NewsRequestArgs(page: 0),
|
||||
'link': localData.link,
|
||||
'goToComment': openComments,
|
||||
};
|
||||
break;
|
||||
|
||||
// Infography & banner: the existing InfographyDetails already
|
||||
// knows how to load by UUID.
|
||||
case 'infography':
|
||||
case 'banner':
|
||||
route = Routes.infographyDetails;
|
||||
args = {
|
||||
'contentUuid': localData.id,
|
||||
'link': localData.link,
|
||||
'goToComment': openComments,
|
||||
};
|
||||
break;
|
||||
|
||||
// Podcast detail page.
|
||||
case 'podcast':
|
||||
route = Routes.studioDetails;
|
||||
args = {
|
||||
'type': 'podcast',
|
||||
'contentUuid': localData.id,
|
||||
'goToComment': openComments,
|
||||
};
|
||||
break;
|
||||
|
||||
// Video / video-cast detail page.
|
||||
case 'video':
|
||||
route = Routes.videoDetails;
|
||||
args = {
|
||||
'contentUuid': localData.id,
|
||||
'goToComment': openComments,
|
||||
};
|
||||
break;
|
||||
|
||||
// Monthly notifications normally arrive with `link` populated and
|
||||
// go to PDFViewer in the `else` branch below. Reaching here means
|
||||
// there's no PDF URL yet — show the list so the user can browse.
|
||||
case 'monthly':
|
||||
route = Routes.monthlyList;
|
||||
break;
|
||||
|
||||
case 'didvanplus':
|
||||
route = Routes.didvanPlusList;
|
||||
break;
|
||||
|
||||
case 'didvanvoice':
|
||||
case 'media':
|
||||
route = Routes.didvanVoiceList;
|
||||
break;
|
||||
|
||||
// Unknown type with a UUID — best effort: generic reader.
|
||||
default:
|
||||
if (kDebugMode) {
|
||||
print("UUID with unmapped type='$type' — defaulting to "
|
||||
"InfographyDetails");
|
||||
}
|
||||
route = Routes.infographyDetails;
|
||||
args = {
|
||||
'contentUuid': localData.id,
|
||||
'link': localData.link,
|
||||
'goToComment': openComments,
|
||||
};
|
||||
}
|
||||
if (kDebugMode) {
|
||||
print("UUID notification routed: type=$type → route=$route");
|
||||
}
|
||||
route = Routes.infographyDetails;
|
||||
args = {
|
||||
'contentUuid': localData.id,
|
||||
'link': localData.link,
|
||||
};
|
||||
} else if (localData.type == null || localData.type!.isEmpty) {
|
||||
if (kDebugMode) {
|
||||
print("=== NAVIGATION ABORTED ===");
|
||||
|
|
|
|||
Loading…
Reference in New Issue