Skip to content

Commit

Permalink
Merge pull request #3703 from TrainLCD/release/v7.7.2
Browse files Browse the repository at this point in the history
v7.7.2🎉
  • Loading branch information
TinyKitten authored Aug 17, 2024
2 parents fd1a447 + a16d0c8 commit f3c06f9
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 54 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ android {
}
prod {
dimension "environment"
versionCode 70701000
versionName "7.7.1"
versionCode 70702000
versionName "7.7.2"
}
}
}// Apply static values from `gradle.properties` to the `android.packagingOptions`
Expand Down
4 changes: 2 additions & 2 deletions android/wearable/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ android {
}
create("prod") {
dimension = "environment"
versionCode = 70701001
versionName = "7.7.1"
versionCode = 70702001
versionName = "7.7.2"
}
}

Expand Down
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import * as TaskManager from 'expo-task-manager'

TaskManager.unregisterAllTasksAsync().catch(console.error)

let lastTimestamp = 0

if (!TaskManager.isTaskDefined(LOCATION_TASK_NAME)) {
TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => {
if (error) {
console.error(error)
return
}

setLocation(data.locations[0])
const latestTimestamp = data.locations[0]?.timestamp ?? 0
if (lastTimestamp < latestTimestamp) {
setLocation(data.locations[0])
lastTimestamp = latestTimestamp
}
})
}

Expand All @@ -18,8 +26,6 @@ import App from './src'
import { LOCATION_TASK_NAME } from './src/constants'
import { setLocation } from './src/hooks/useLocationStore'

TaskManager.unregisterAllTasksAsync().catch(console.error)

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in the Expo client or in a native build,
// the environment is set up appropriately
Expand Down
12 changes: 6 additions & 6 deletions ios/TrainLCD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.7.1;
MARKETING_VERSION = 7.7.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1489,7 +1489,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 7.7.1;
MARKETING_VERSION = 7.7.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -2131,7 +2131,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 7.7.1;
MARKETING_VERSION = 7.7.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -2175,7 +2175,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 7.7.1;
MARKETING_VERSION = 7.7.2;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE -D EXPO_CONFIGURATION_DEBUG";
PRODUCT_BUNDLE_IDENTIFIER = me.tinykitten.trainlcd.watchkitapp.watchkitextension;
Expand Down Expand Up @@ -2213,7 +2213,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Schemes/Prod/Info.plist;
MARKETING_VERSION = 7.7.1;
MARKETING_VERSION = 7.7.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -2253,7 +2253,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Schemes/Prod/Info.plist;
MARKETING_VERSION = 7.7.1;
MARKETING_VERSION = 7.7.2;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE -D EXPO_CONFIGURATION_DEBUG";
PRODUCT_BUNDLE_IDENTIFIER = me.tinykitten.trainlcd.watchkitapp;
Expand Down
6 changes: 4 additions & 2 deletions src/components/LineBoardWest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ const StationNameCell: React.FC<StationNameCellProps> = ({

const LineBoardWest: React.FC<Props> = ({ stations, lineColors }: Props) => {
const { selectedLine } = useRecoilValue(lineState)
const { arrived, approaching } = useRecoilValue(stationState)

const isPassing = useIsPassing()
const currentLine = useCurrentLine()

Expand All @@ -448,11 +450,11 @@ const LineBoardWest: React.FC<Props> = ({ stations, lineColors }: Props) => {
key={s.groupId}
station={s}
stations={stations}
arrived={!isPassing}
arrived={!isPassing && !approaching && arrived}
index={i}
/>
),
[isPassing, stations]
[approaching, arrived, isPassing, stations]
)

const emptyArray = useMemo(
Expand Down
72 changes: 42 additions & 30 deletions src/hooks/useSavedRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,55 @@
import firestore from '@react-native-firebase/firestore'
import { useCallback, useEffect, useState } from 'react'
import useSWR from 'swr'
import useSWRMutation from 'swr/dist/mutation'
import { GetStationByIdListRequest } from '../../gen/proto/stationapi_pb'
import { grpcClient } from '../lib/grpc'
import { SavedRoute } from '../models/SavedRoute'
import useCachedInitAnonymousUser from './useCachedAnonymousUser'

export const useSavedRoutes = () => {
useCachedInitAnonymousUser()
const [routes, setRoutes] = useState<SavedRoute[]>([])
const [loading, setLoading] = useState(false)

useEffect(() => {
const fetchRoutesAsync = async () => {
setLoading(true)
const routesSnapshot = await firestore()
.collection('uploadedCommunityRoutes')
.orderBy('createdAt', 'desc')
.get()
const routes = routesSnapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
const {
data: routes,
isLoading: isRoutesLoading,
error: fetchRoutesError,
} = useSWR<SavedRoute[]>('/firestore/uploadedCommunityRoutes', async () => {
const routesSnapshot = await firestore()
.collection('uploadedCommunityRoutes')
.orderBy('createdAt', 'desc')
.get()

return routesSnapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
})) as SavedRoute[]
})

const {
isMutating: isStationsLoading,
error: fetchStationsError,
trigger: fetchStationsByRoute,
} = useSWRMutation(
'/app.trainlcd.grpc/GetStationByIdListRequest',
async (_, { arg: route }: { arg: SavedRoute }) => {
const req = new GetStationByIdListRequest()
req.ids = route.stations.map((sta) => sta.id)
const res = await grpcClient.getStationByIdList(req, {})
const stations = res?.stations ?? []

return stations.map((sta) => ({
...sta,
stopCondition: route.stations.find((rs) => rs.id === sta.id)
?.stopCondition,
trainType: route.trainType,
}))
setRoutes(routes as SavedRoute[])
setLoading(false)
}
fetchRoutesAsync()
}, [])

const fetchStationsByRoute = useCallback(async (route: SavedRoute) => {
const req = new GetStationByIdListRequest()
req.ids = route.stations.map((sta) => sta.id)
const res = await grpcClient.getStationByIdList(req, {})
const stations = res?.stations ?? []
return stations.map((sta, idx) => ({
...sta,
stopCondition: route.stations[idx].stopCondition,
trainType: route.trainType,
}))
}, [])
)

return { routes, loading, fetchStationsByRoute }
return {
routes,
loading: isRoutesLoading || isStationsLoading,
error: fetchRoutesError || fetchStationsError,
fetchStationsByRoute,
}
}
29 changes: 20 additions & 9 deletions src/hooks/useStartBackgroundLocationUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@ export const useStartBackgroundLocationUpdates = () => {
if (autoModeEnabled) {
return
}
Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
accuracy: Location.Accuracy.High,
distanceInterval: 100,
foregroundService: {
notificationTitle: translate('bgAlertTitle'),
notificationBody: translate('bgAlertContent'),
killServiceOnDestroy: true,
},
})
// eslint-disable-next-line @typescript-eslint/no-extra-semi
;(async () => {
if (
!(await Location.hasStartedLocationUpdatesAsync(LOCATION_TASK_NAME))
) {
Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
// NOTE: BestForNavigationにしたら暴走時のCPU使用率が50%ほど低下した
accuracy: Location.Accuracy.BestForNavigation,
// NOTE: マップマッチが勝手に行われると電車での経路と大きく異なることがあるはずなので
// OtherNavigationは必須
activityType: Location.ActivityType.OtherNavigation,
distanceInterval: 100,
foregroundService: {
notificationTitle: translate('bgAlertTitle'),
notificationBody: translate('bgAlertContent'),
killServiceOnDestroy: true,
},
})
}
})()

return () => {
Location.stopLocationUpdatesAsync(LOCATION_TASK_NAME).catch(console.debug)
Expand Down

0 comments on commit f3c06f9

Please sign in to comment.