From cfcc13bb39e0027a7da56d1ffc6df0bc4c03cce4 Mon Sep 17 00:00:00 2001 From: Matan Mashraki <12946462+planecore@users.noreply.github.com> Date: Sat, 13 Apr 2024 15:12:17 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20-=20Auto=20import=20favorite=20stat?= =?UTF-8?q?ions=20to=20service=20updates=20(#364)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 2 +- app/i18n/ar.json | 2 + app/i18n/en.json | 2 + app/i18n/he.json | 4 +- app/i18n/ru.json | 2 + .../notifications-setup-screen.tsx | 111 ++++++++++++------ app/utils/notification-helpers.ts | 6 +- ios/BetterRail/Info.plist | 2 +- ios/BetterRailWidget/Info.plist | 2 +- ios/BetterRailWidget/WatchInfo.plist | 2 +- ios/Podfile.lock | 12 -- ios/StationIntent/Info.plist | 2 +- 12 files changed, 91 insertions(+), 58 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index e8975305..1196924d 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -120,7 +120,7 @@ android { applicationId "com.betterrail" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 81 + versionCode 82 versionName "2.3.0" missingDimensionStrategy "store", "play" } diff --git a/app/i18n/ar.json b/app/i18n/ar.json index 8e4d4ce8..20eacb33 100644 --- a/app/i18n/ar.json +++ b/app/i18n/ar.json @@ -176,8 +176,10 @@ "enableNotifications": "تفعيل الإشعارات", "notificationSetupContent": "سوف يرسل لك Better Rail تحديثات حول الأحداث المتعلقة بالمحطات التي اخترتها", + "stations": "محطات", "selectStations": "اختر المحطات", "selectedStations": "المحطات المختارة", + "stationsFromFavorites": "من الطرق المفضلة", "notificationNote": "يرجى الملاحظة: بينما سيبذل Better Rail قصارى جهده لتوفير تحديثات سريعة وموثوقة، يُنصح دائمًا بالتحقق من المصادر الرسمية لسكك حديد إسرائيل كذلك." } diff --git a/app/i18n/en.json b/app/i18n/en.json index e36104f9..07aa6838 100644 --- a/app/i18n/en.json +++ b/app/i18n/en.json @@ -268,8 +268,10 @@ "enableNotifications": "Enable Notifications", "notificationSetupContent": "Better Rail will send you updates on events related to your selected stations", + "stations": "Stations", "selectStations": "Select Stations", "selectedStations": "Selected Stations", + "stationsFromFavorites": "From Favorite Routes", "notificationNote": "Please note: While Better Rail will do its best to provide fast and reliable updates, it is always advisable to check with the official sources of Israel Railways as well." } diff --git a/app/i18n/he.json b/app/i18n/he.json index 328cd6e0..335a3a33 100644 --- a/app/i18n/he.json +++ b/app/i18n/he.json @@ -272,8 +272,10 @@ "enableNotifications": "הפעלת התראות", "notificationSetupContent": "בטר רייל תשלח התראות רלוונטיות לתחנות המועדפות עליכם", + "stations": "תחנות", "selectStations": "בחירת תחנות", - "selectedStations": "תחנות", + "selectedStations": "תחנות נוספות", + "stationsFromFavorites": "תחנות ממסלולים מועדפים", "notificationNote": "בטר רייל תעשה כמיטב יכולתה לספק עדכונים מהירים ואמינים, אך תמיד מומלץ לבדוק גם עם המקורות הרשמיים של רכבת ישראל." } diff --git a/app/i18n/ru.json b/app/i18n/ru.json index 4e2a6741..962dbf0f 100644 --- a/app/i18n/ru.json +++ b/app/i18n/ru.json @@ -179,8 +179,10 @@ "enableNotifications": "Включить уведомления", "notificationSetupContent": "Better Rail будет отправлять вам обновления о событиях, связанных с выбранными вами станциями", + "stations": "Станции", "selectStations": "Выбрать станции", "selectedStations": "Выбранные станции", + "stationsFromFavorites": "Из любимых маршрутов", "notificationNote": "Обратите внимание: хотя Better Rail и будет стараться предоставлять быстрые и надежные обновления, всегда рекомендуется проверять информацию у официальных источников Израильских железных дорог." } diff --git a/app/screens/notifications/notifications-setup-screen.tsx b/app/screens/notifications/notifications-setup-screen.tsx index 014e2bb0..4c8e89e3 100644 --- a/app/screens/notifications/notifications-setup-screen.tsx +++ b/app/screens/notifications/notifications-setup-screen.tsx @@ -12,9 +12,10 @@ import { useStations } from "../../data/stations" import analytics from "@react-native-firebase/analytics" import messaging from "@react-native-firebase/messaging" import { useAppState } from "../../hooks" +import { chain } from "lodash" export const NotificationsSetupScreen = observer(function NotificationsSetupScreen({ navigation }: AnnouncementsScreenProps) { - const { settings } = useStores() + const { settings, favoriteRoutes } = useStores() const stations = useStations() const appState = useAppState() const [notificationPermission, setNotificationPermission] = useState(false) @@ -67,50 +68,84 @@ export const NotificationsSetupScreen = observer(function NotificationsSetupScre } }, [notificationPermission]) + const favoriteStations = chain(favoriteRoutes.routes) + .flatMap((route) => [route.originId, route.destinationId]) + .uniq() + .filter((station) => !settings.stationsNotifications.includes(station)) + .value() + return ( - + - - 🔔 - - - - {notificationPermission ? ( - -