forked from eatvio/eatvio_app
Merge pull request 'fix 939, 927' (#940) from mso7nueh/eatvio_app:main into main
Reviewed-on: eatvio/eatvio_app#940 Reviewed-by: misha <misha@noreply.localhost>
This commit is contained in:
@@ -55,32 +55,19 @@
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" />
|
||||
|
||||
<!-- Main domains -->
|
||||
<data android:host="eatvio.ru" />
|
||||
<data android:host="www.eatvio.ru" />
|
||||
<data android:host="eatvio.com" />
|
||||
<data android:host="www.eatvio.com" />
|
||||
|
||||
<!-- Development/Subdomains -->
|
||||
<data android:host="*.eatvio.ru" />
|
||||
<data android:host="*.eatvio.com" />
|
||||
|
||||
<data android:pathPattern="/ru/recipe/.*" />
|
||||
<data android:pathPattern="/en/recipe/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/blog_post/.*" />
|
||||
<data android:pathPattern="/en/blog_post/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/diet/.*" />
|
||||
<data android:pathPattern="/en/diet/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/plan/.*" />
|
||||
<data android:pathPattern="/en/plan/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/chat/.*" />
|
||||
<data android:pathPattern="/en/chat/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/chat" />
|
||||
<data android:pathPattern="/en/chat" />
|
||||
|
||||
<data android:pathPattern="/ru/profile/.*" />
|
||||
<data android:pathPattern="/en/profile/.*" />
|
||||
|
||||
<data android:pathPattern="/ru/diary/.*" />
|
||||
<data android:pathPattern="/en/diary/.*" />
|
||||
<!-- Simplify patterns to allow navigation within the app for all matching hosts -->
|
||||
<data android:pathPattern="/.*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- Don't delete the meta-data below.
|
||||
|
||||
@@ -15,7 +15,7 @@ class AppRouter {
|
||||
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
// Домены для deep links (в т.ч. ссылки из пушей dev2.eatvio.com)
|
||||
static const List<String> _deepLinkHosts = ['eatvio.ru', 'www.eatvio.ru'];
|
||||
static const List<String> deepLinkHosts = ['eatvio.ru', 'eatvio.com'];
|
||||
|
||||
static GoRouter appRouter = GoRouter(
|
||||
initialLocation: RouteConstants.updateScreen,
|
||||
@@ -34,7 +34,8 @@ class AppRouter {
|
||||
final host = uri.host.toLowerCase();
|
||||
final segments = uri.pathSegments;
|
||||
|
||||
final isDeepLink = _deepLinkHosts.contains(host);
|
||||
// Проверяем, что хост заканчивается на один из разрешенных доменов
|
||||
final isDeepLink = deepLinkHosts.any((allowedHost) => host == allowedHost || host.endsWith('.$allowedHost'));
|
||||
|
||||
if (!isDeepLink) {
|
||||
return null;
|
||||
@@ -48,6 +49,7 @@ class AppRouter {
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
|
||||
// Обработка api ссылок (например, из пушей чата)
|
||||
if (segments.length >= 4 &&
|
||||
segments[0] == 'api' &&
|
||||
segments[1] == 'v2' &&
|
||||
@@ -58,33 +60,32 @@ class AppRouter {
|
||||
return RouteConstants.chatSelectScreen;
|
||||
}
|
||||
|
||||
if (segments[0] != 'ru' && segments[0] != 'en') {
|
||||
developer.log('Invalid language segment: ${segments[0]}, redirecting to feed', name: 'AppRouter');
|
||||
// Определяем, есть ли в начале сегмент языка (ru/en). Если есть — пропускаем его.
|
||||
int startIndex = 0;
|
||||
if (segments[0] == 'ru' || segments[0] == 'en') {
|
||||
startIndex = 1;
|
||||
} else {
|
||||
developer.log('Deep link without language segment: ${segments[0]}', name: 'AppRouter');
|
||||
}
|
||||
|
||||
final effectiveSegments = segments.sublist(startIndex);
|
||||
if (effectiveSegments.isEmpty) {
|
||||
developer.log('No effective segments after language check, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
|
||||
if (segments.length == 4) {
|
||||
final type = segments[1];
|
||||
final type = effectiveSegments[0];
|
||||
|
||||
if (type == 'diary') {
|
||||
developer.log('Deep link: diary, redirecting to diary-screen', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.diaryScreen;
|
||||
}
|
||||
if (type == 'consultations' && segments[2] == 'status') {
|
||||
final consultationId = segments[3];
|
||||
developer.log('Deep link: consultations/status/$consultationId', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '${RouteConstants.consultationsScreen}?id=$consultationId';
|
||||
}
|
||||
|
||||
developer.log('Unknown deep link type for 4 segments: $type, redirecting to feed', name: 'AppRouter');
|
||||
if (effectiveSegments.length == 3 && type == 'consultations' && effectiveSegments[1] == 'status') {
|
||||
final consultationId = effectiveSegments[2];
|
||||
developer.log('Deep link: consultations/status/$consultationId', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
} else if (segments.length == 3) {
|
||||
final type = segments[1];
|
||||
final contentIdentifier = segments[2];
|
||||
return '${RouteConstants.consultationsScreen}?id=$consultationId';
|
||||
}
|
||||
|
||||
if (effectiveSegments.length == 2) {
|
||||
final contentIdentifier = effectiveSegments[1];
|
||||
|
||||
switch (type) {
|
||||
case 'recipe':
|
||||
@@ -99,31 +100,26 @@ class AppRouter {
|
||||
developer.log('Deep link: plan/$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '/about-plan-screen?slug=$contentIdentifier';
|
||||
case 'diet': {
|
||||
final dietId = int.tryParse(contentIdentifier);
|
||||
if (dietId != null) {
|
||||
developer.log('Deep link: diet/id=$dietId', name: 'AppRouter');
|
||||
case 'diet':
|
||||
{
|
||||
final dietId = int.tryParse(contentIdentifier);
|
||||
if (dietId != null) {
|
||||
developer.log('Deep link: diet/id=$dietId', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '/about-diet-screen?id=$dietId';
|
||||
}
|
||||
developer.log('Deep link: diet/slug=$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '/about-diet-screen?id=$dietId';
|
||||
return '/about-diet-screen?slug=$contentIdentifier';
|
||||
}
|
||||
developer.log('Deep link: diet/slug=$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '/about-diet-screen?slug=$contentIdentifier';
|
||||
}
|
||||
case 'chat':
|
||||
developer.log('Deep link: chat/$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.chatSelectScreen;
|
||||
case 'profile':
|
||||
// В диплинке передан slug — открываем профиль пользователя по slug.
|
||||
developer.log('Deep link: profile/$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return '/profile-screen?slug=$contentIdentifier';
|
||||
case 'badge':
|
||||
// В badge нет slug, открываем вкладку «Мой профиль».
|
||||
developer.log('Deep link: badge → my-profile tab', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.myProfileScreen;
|
||||
case 'diary':
|
||||
developer.log('Deep link: diary/$contentIdentifier', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
@@ -132,14 +128,10 @@ class AppRouter {
|
||||
developer.log('Deep link: consultant_diary_comment/$contentIdentifier → diary', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.diaryScreen;
|
||||
default:
|
||||
developer.log('Unknown deep link type: $type, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
} else if (segments.length == 2) {
|
||||
final type = segments[1];
|
||||
}
|
||||
|
||||
if (effectiveSegments.length == 1) {
|
||||
if (type == 'chat') {
|
||||
developer.log('Deep link: chat', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
@@ -150,13 +142,14 @@ class AppRouter {
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.diaryScreen;
|
||||
}
|
||||
|
||||
developer.log('Unknown deep link type for 2 segments: $type, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
if (type == 'badge') {
|
||||
developer.log('Deep link: badge → my-profile tab', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.myProfileScreen;
|
||||
}
|
||||
}
|
||||
|
||||
developer.log('Unknown deep link format: ${segments.length} segments, redirecting to feed', name: 'AppRouter');
|
||||
developer.log('Unknown deep link format: ${effectiveSegments.length} effective segments, type=$type, redirecting to feed', name: 'AppRouter');
|
||||
FlutterNativeSplash.remove();
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
@@ -190,7 +183,7 @@ class AppRouter {
|
||||
if (uri.host.isEmpty && uri.pathSegments.isNotEmpty) {
|
||||
uri = Uri(
|
||||
scheme: 'https',
|
||||
host: _deepLinkHosts.first,
|
||||
host: deepLinkHosts.first,
|
||||
pathSegments: uri.pathSegments,
|
||||
queryParameters: uri.queryParameters.isEmpty ? null : uri.queryParameters,
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:developer' as developer;
|
||||
|
||||
import 'package:eatvio_app/core/app_router.dart';
|
||||
import 'package:eatvio_app/core/routing/route_constants.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -69,23 +70,94 @@ class PushNavigationHandler {
|
||||
}
|
||||
|
||||
static void _handleMessageInternal(RemoteMessage message, {required String source}) {
|
||||
final data = message.data;
|
||||
final actionUrl = data['action_url'] as String?;
|
||||
developer.log(
|
||||
'PushNavigationHandler: received message. data=${message.data}, notification=${message.notification?.title}, source=$source',
|
||||
name: 'PushNavigationHandler',
|
||||
);
|
||||
|
||||
if (actionUrl == null || actionUrl.isEmpty) {
|
||||
final data = message.data;
|
||||
|
||||
// Пытаемся взять URL из action_url или action (бэкенд шлёт и то и другое)
|
||||
String? rawUrl = data['action_url'] as String?;
|
||||
if (rawUrl == null || rawUrl.isEmpty) {
|
||||
rawUrl = data['action'] as String?;
|
||||
}
|
||||
|
||||
if (rawUrl != null && rawUrl.isNotEmpty) {
|
||||
developer.log(
|
||||
'PushNavigationHandler: no action_url in message data, source=$source, data=$data',
|
||||
'PushNavigationHandler: manual navigation by url=$rawUrl, source=$source',
|
||||
name: 'PushNavigationHandler',
|
||||
);
|
||||
|
||||
// Если это URL, но без схемы, добавляем https
|
||||
String finalUrl = rawUrl;
|
||||
if (!finalUrl.startsWith('http') && finalUrl.contains('/')) {
|
||||
finalUrl = 'https://${AppRouter.deepLinkHosts.first}/$finalUrl'.replaceAll('//', '/').replaceFirst('https:/', 'https://');
|
||||
}
|
||||
|
||||
AppRouter.navigateByDeepLinkUrl(finalUrl);
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback: навигация по типу уведомления, если URL отсутствует.
|
||||
final target = _resolveTargetByType(data);
|
||||
if (target != null) {
|
||||
developer.log(
|
||||
'PushNavigationHandler: fallback navigation by type, target=$target, source=$source, data=$data',
|
||||
name: 'PushNavigationHandler',
|
||||
);
|
||||
AppRouter.appRouter.go(target);
|
||||
return;
|
||||
}
|
||||
|
||||
developer.log(
|
||||
'PushNavigationHandler: navigating by action_url=$actionUrl, source=$source',
|
||||
'PushNavigationHandler: no action_url/action and no known type, source=$source, data=$data',
|
||||
name: 'PushNavigationHandler',
|
||||
);
|
||||
}
|
||||
|
||||
AppRouter.navigateByDeepLinkUrl(actionUrl);
|
||||
/// Определяет маршрут по полям `type` / `action` из data, если URL отсутствует.
|
||||
static String? _resolveTargetByType(Map<String, dynamic> data) {
|
||||
final type = data['type'] as String? ?? '';
|
||||
final action = data['action'] as String? ?? '';
|
||||
final databaseType = data['database_type'] as String? ?? '';
|
||||
|
||||
// Чат
|
||||
if (type == 'chat_message' || databaseType == 'chat-message') {
|
||||
return RouteConstants.chatSelectScreen;
|
||||
}
|
||||
|
||||
// Дневник
|
||||
if (type == 'diary_reminder' || action == 'open_diary' || databaseType == 'diary-reminder') {
|
||||
return RouteConstants.diaryScreen;
|
||||
}
|
||||
|
||||
// Комментарий консультанта к дневнику
|
||||
if (type == 'consultant_diary_comment' || databaseType == 'consultant-left-diary-comment') {
|
||||
return RouteConstants.diaryScreen;
|
||||
}
|
||||
|
||||
// Консультации (plan-related)
|
||||
if (type.startsWith('plan_') || type.startsWith('chosen_plan_') || databaseType.contains('plan')) {
|
||||
return RouteConstants.consultationsScreen;
|
||||
}
|
||||
|
||||
// Диета
|
||||
if (type == 'diet_started' || type == 'diet_cancelled' || databaseType.startsWith('diet-')) {
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
|
||||
// Бейдж
|
||||
if (type == 'badge_awarded' || databaseType == 'badge-awarded') {
|
||||
return RouteConstants.myProfileScreen;
|
||||
}
|
||||
|
||||
// Мотивация
|
||||
if (type == 'motivation') {
|
||||
return RouteConstants.feedScreen;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -257,12 +257,17 @@ class _GlossaryModerationRequestModalWidgetState extends State<GlossaryModeratio
|
||||
const SizedBox(height: 12),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final energy = double.tryParse(energyController.text.replaceAll(',', '.')) ?? 0;
|
||||
final proteins = double.tryParse(proteinsController.text.replaceAll(',', '.')) ?? 0;
|
||||
final fats = double.tryParse(fatsController.text.replaceAll(',', '.')) ?? 0;
|
||||
final carbohydrates = double.tryParse(carbohydratesController.text.replaceAll(',', '.')) ?? 0;
|
||||
|
||||
glossary = (await widget.diaryCubit.sendProductToModeration(
|
||||
name: productNameController.text,
|
||||
energy: double.parse(energyController.text.replaceAll(',', '.')),
|
||||
proteins: double.parse(proteinsController.text.replaceAll(',', '.')),
|
||||
fats: double.parse(fatsController.text.replaceAll(',', '.')),
|
||||
carbohydrates: double.parse(carbohydratesController.text.replaceAll(',', '.')),
|
||||
energy: energy,
|
||||
proteins: proteins,
|
||||
fats: fats,
|
||||
carbohydrates: carbohydrates,
|
||||
))?.glossary;
|
||||
setState(() {
|
||||
glossaryState = GlossaryState.success;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/features/diary/models/consultant_comment_model.dart';
|
||||
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
|
||||
import 'package:eatvio_app/features/diary/models/create_day_model.dart';
|
||||
@@ -381,7 +382,10 @@ class DiaryRepository {
|
||||
await diaryService.createDay(body: CreateDayModel(day: day));
|
||||
await getDiaryByDate(day);
|
||||
} catch (e, s) {
|
||||
await Sentry.captureException(e, stackTrace: s);
|
||||
if (e is DioException && e.response?.statusCode == 422) {
|
||||
} else {
|
||||
await Sentry.captureException(e, stackTrace: s);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: eatvio_app
|
||||
description: A new Flutter project.
|
||||
version: 1.3.18+98
|
||||
version: 1.3.19+99
|
||||
publish_to: 'none'
|
||||
|
||||
environment:
|
||||
|
||||
Reference in New Issue
Block a user