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 ||
|
if (localData.link.toString().isEmpty ||
|
||||||
localData.link.toString() == "null") {
|
localData.link.toString() == "null") {
|
||||||
// ---------------- UUID short-circuit ----------------
|
// ---------------- UUID short-circuit ----------------
|
||||||
// Content from the new content-service uses UUIDs (e.g. cdaa8830-…).
|
// Content from the new content-service uses UUIDs. The legacy routes
|
||||||
// The legacy routes below assume int IDs, so for any UUID we route
|
// below assume int IDs and can't be reached for UUID content. Route
|
||||||
// straight to InfographyDetails which knows how to fetch by UUID
|
// by `type` to the matching detail screen, all of which know how to
|
||||||
// from content-service.
|
// hydrate from content-service when given `contentUuid`.
|
||||||
//
|
//
|
||||||
// Exception: trend / technology / startup intentionally render in
|
// Exception: trend / technology / startup intentionally render in
|
||||||
// their dedicated web apps (trend.didvan.app, tech.didvan.app,
|
// their dedicated webview — those fall through to the legacy switch
|
||||||
// startup.didvan.app) — for those types we fall through to the
|
// below so the URL is constructed and opened in a WebView even when
|
||||||
// legacy switch below so the URL is constructed and opened in a
|
// the id is a UUID.
|
||||||
// WebView, even when the id is a UUID.
|
|
||||||
const _webViewTypes = {'trend', 'technology', 'startup'};
|
const _webViewTypes = {'trend', 'technology', 'startup'};
|
||||||
final _isWebViewType = _webViewTypes.contains(localData.type);
|
final _isWebViewType = _webViewTypes.contains(localData.type);
|
||||||
if (_isUuid(localData.id) && !_isWebViewType) {
|
if (_isUuid(localData.id) && !_isWebViewType) {
|
||||||
|
// 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) {
|
if (kDebugMode) {
|
||||||
print("UUID detected — routing to InfographyDetails for "
|
print("UUID with unmapped type='$type' — defaulting to "
|
||||||
"type='${localData.type}' id=${localData.id}");
|
"InfographyDetails");
|
||||||
}
|
}
|
||||||
route = Routes.infographyDetails;
|
route = Routes.infographyDetails;
|
||||||
args = {
|
args = {
|
||||||
'contentUuid': localData.id,
|
'contentUuid': localData.id,
|
||||||
'link': localData.link,
|
'link': localData.link,
|
||||||
|
'goToComment': openComments,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
if (kDebugMode) {
|
||||||
|
print("UUID notification routed: type=$type → route=$route");
|
||||||
|
}
|
||||||
} else if (localData.type == null || localData.type!.isEmpty) {
|
} else if (localData.type == null || localData.type!.isEmpty) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print("=== NAVIGATION ABORTED ===");
|
print("=== NAVIGATION ABORTED ===");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue