diff --git a/android/Gemfile.lock b/android/Gemfile.lock index d2f5c5613..8c75723dc 100644 --- a/android/Gemfile.lock +++ b/android/Gemfile.lock @@ -1,29 +1,32 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.6) + CFPropertyList (3.0.7) + base64 + nkf rexml - addressable (2.8.5) - public_suffix (>= 2.0.2, < 6.0) - artifactory (3.0.15) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + artifactory (3.0.17) atomos (0.1.3) - aws-eventstream (1.2.0) - aws-partitions (1.825.0) - aws-sdk-core (3.182.0) - aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.5) + aws-eventstream (1.3.0) + aws-partitions (1.995.0) + aws-sdk-core (3.211.0) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.992.0) + aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.71.0) - aws-sdk-core (~> 3, >= 3.177.0) - aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.134.0) - aws-sdk-core (~> 3, >= 3.181.0) + aws-sdk-kms (1.95.0) + aws-sdk-core (~> 3, >= 3.210.0) + aws-sigv4 (~> 1.5) + aws-sdk-s3 (1.169.0) + aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.6) - aws-sigv4 (1.6.0) + aws-sigv4 (~> 1.5) + aws-sigv4 (1.10.1) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) + base64 (0.2.0) claide (1.1.0) colored (1.2) colored2 (3.1.2) @@ -32,12 +35,11 @@ GEM declarative (0.0.20) digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) + domain_name (0.6.20240107) dotenv (2.8.1) emoji_regex (3.2.3) - excon (0.103.0) - faraday (1.10.3) + excon (0.112.0) + faraday (1.10.4) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -58,22 +60,22 @@ GEM faraday-httpclient (1.0.1) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (1.0.1) + faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - faraday_middleware (1.2.0) + faraday_middleware (1.2.1) faraday (~> 1.0) - fastimage (2.2.7) - fastlane (2.216.0) + fastimage (2.3.1) + fastlane (2.225.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) aws-sdk-s3 (~> 1.0) babosa (>= 1.0.3, < 2.0.0) bundler (>= 1.12.0, < 3.0.0) - colored + colored (~> 1.2) commander (~> 4.6) dotenv (>= 2.1.1, < 3.0.0) emoji_regex (>= 0.1, < 4.0) @@ -82,9 +84,11 @@ GEM faraday-cookie_jar (~> 0.0.6) faraday_middleware (~> 1.0) fastimage (>= 2.1.0, < 3.0.0) + fastlane-sirp (>= 1.0.0) gh_inspector (>= 1.1.2, < 2.0.0) google-apis-androidpublisher_v3 (~> 0.3) google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-env (>= 1.6.0, < 2.0.0) google-cloud-storage (~> 1.31) highline (~> 2.0) http-cookie (~> 1.0.5) @@ -93,10 +97,10 @@ GEM mini_magick (>= 4.9.4, < 5.0.0) multipart-post (>= 2.0.0, < 3.0.0) naturally (~> 2.2) - optparse (~> 0.1.1) + optparse (>= 0.1.1, < 1.0.0) plist (>= 3.1.0, < 4.0.0) rubyzip (>= 2.0.0, < 3.0.0) - security (= 0.1.3) + security (= 0.1.5) simctl (~> 1.6.3) terminal-notifier (>= 2.0.0, < 3.0.0) terminal-table (~> 3) @@ -105,11 +109,13 @@ GEM word_wrap (~> 1.0.0) xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) - xcpretty-travis-formatter (>= 0.0.3) + xcpretty-travis-formatter (>= 0.0.3, < 2.0.0) + fastlane-sirp (1.0.0) + sysrandom (~> 1.0) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.49.0) + google-apis-androidpublisher_v3 (0.54.0) google-apis-core (>= 0.11.0, < 2.a) - google-apis-core (0.11.1) + google-apis-core (0.11.3) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -117,62 +123,63 @@ GEM representable (~> 3.0) retriable (>= 2.0, < 4.a) rexml - webrick google-apis-iamcredentials_v1 (0.17.0) google-apis-core (>= 0.11.0, < 2.a) google-apis-playcustomapp_v1 (0.13.0) google-apis-core (>= 0.11.0, < 2.a) - google-apis-storage_v1 (0.19.0) - google-apis-core (>= 0.9.0, < 2.a) - google-cloud-core (1.6.0) - google-cloud-env (~> 1.0) + google-apis-storage_v1 (0.31.0) + google-apis-core (>= 0.11.0, < 2.a) + google-cloud-core (1.7.1) + google-cloud-env (>= 1.0, < 3.a) google-cloud-errors (~> 1.0) google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) - google-cloud-errors (1.3.1) - google-cloud-storage (1.44.0) + google-cloud-errors (1.4.0) + google-cloud-storage (1.47.0) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-iamcredentials_v1 (~> 0.1) - google-apis-storage_v1 (~> 0.19.0) + google-apis-storage_v1 (~> 0.31.0) google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - googleauth (1.8.0) + googleauth (1.8.1) faraday (>= 0.17.3, < 3.a) jwt (>= 1.4, < 3.0) multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) highline (2.0.3) - http-cookie (1.0.5) + http-cookie (1.0.7) domain_name (~> 0.5) httpclient (2.8.3) jmespath (1.6.2) - json (2.6.3) - jwt (2.7.1) - mini_magick (4.12.0) + json (2.7.3) + jwt (2.9.3) + base64 + mini_magick (4.13.2) mini_mime (1.1.5) multi_json (1.15.0) - multipart-post (2.3.0) + multipart-post (2.4.1) nanaimo (0.3.0) naturally (2.2.1) - optparse (0.1.1) + nkf (0.2.0) + optparse (0.5.0) os (1.1.4) - plist (3.7.0) - public_suffix (5.0.3) - rake (13.0.6) + plist (3.7.1) + public_suffix (6.0.1) + rake (13.2.1) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.2.6) + rexml (3.3.9) rouge (2.0.7) ruby2_keywords (0.0.5) rubyzip (2.3.2) - security (0.1.3) - signet (0.18.0) + security (0.1.5) + signet (0.19.0) addressable (~> 2.8) faraday (>= 0.17.5, < 3.a) jwt (>= 1.5, < 3.0) @@ -180,28 +187,25 @@ GEM simctl (1.6.10) CFPropertyList naturally + sysrandom (1.0.5) terminal-notifier (2.0.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) trailblazer-option (0.1.2) tty-cursor (0.7.1) - tty-screen (0.8.1) + tty-screen (0.8.2) tty-spinner (0.9.3) tty-cursor (~> 0.7) uber (0.1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) - unicode-display_width (2.4.2) - webrick (1.8.1) + unicode-display_width (2.6.0) word_wrap (1.0.0) - xcodeproj (1.22.0) + xcodeproj (1.25.1) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) - rexml (~> 3.2.4) + rexml (>= 3.3.6, < 4.0) xcpretty (0.3.0) rouge (~> 2.0.7) xcpretty-travis-formatter (1.0.1) diff --git a/ios/Gemfile.lock b/ios/Gemfile.lock index 96a66bb61..520f8f2fb 100644 --- a/ios/Gemfile.lock +++ b/ios/Gemfile.lock @@ -1,29 +1,32 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.6) + CFPropertyList (3.0.7) + base64 + nkf rexml - addressable (2.8.5) - public_suffix (>= 2.0.2, < 6.0) - artifactory (3.0.15) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + artifactory (3.0.17) atomos (0.1.3) - aws-eventstream (1.2.0) - aws-partitions (1.844.0) - aws-sdk-core (3.186.0) - aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.5) + aws-eventstream (1.3.0) + aws-partitions (1.995.0) + aws-sdk-core (3.211.0) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.992.0) + aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.72.0) - aws-sdk-core (~> 3, >= 3.184.0) - aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.136.0) - aws-sdk-core (~> 3, >= 3.181.0) + aws-sdk-kms (1.95.0) + aws-sdk-core (~> 3, >= 3.210.0) + aws-sigv4 (~> 1.5) + aws-sdk-s3 (1.169.0) + aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.6) - aws-sigv4 (1.6.1) + aws-sigv4 (~> 1.5) + aws-sigv4 (1.10.1) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) + base64 (0.2.0) claide (1.1.0) colored (1.2) colored2 (3.1.2) @@ -32,12 +35,11 @@ GEM declarative (0.0.20) digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) + domain_name (0.6.20240107) dotenv (2.8.1) emoji_regex (3.2.3) - excon (0.104.0) - faraday (1.10.3) + excon (0.112.0) + faraday (1.10.4) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -58,22 +60,22 @@ GEM faraday-httpclient (1.0.1) faraday-multipart (1.0.4) multipart-post (~> 2) - faraday-net_http (1.0.1) + faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - faraday_middleware (1.2.0) + faraday_middleware (1.2.1) faraday (~> 1.0) - fastimage (2.2.7) - fastlane (2.216.0) + fastimage (2.3.1) + fastlane (2.225.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) aws-sdk-s3 (~> 1.0) babosa (>= 1.0.3, < 2.0.0) bundler (>= 1.12.0, < 3.0.0) - colored + colored (~> 1.2) commander (~> 4.6) dotenv (>= 2.1.1, < 3.0.0) emoji_regex (>= 0.1, < 4.0) @@ -82,9 +84,11 @@ GEM faraday-cookie_jar (~> 0.0.6) faraday_middleware (~> 1.0) fastimage (>= 2.1.0, < 3.0.0) + fastlane-sirp (>= 1.0.0) gh_inspector (>= 1.1.2, < 2.0.0) google-apis-androidpublisher_v3 (~> 0.3) google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-env (>= 1.6.0, < 2.0.0) google-cloud-storage (~> 1.31) highline (~> 2.0) http-cookie (~> 1.0.5) @@ -93,10 +97,10 @@ GEM mini_magick (>= 4.9.4, < 5.0.0) multipart-post (>= 2.0.0, < 3.0.0) naturally (~> 2.2) - optparse (~> 0.1.1) + optparse (>= 0.1.1, < 1.0.0) plist (>= 3.1.0, < 4.0.0) rubyzip (>= 2.0.0, < 3.0.0) - security (= 0.1.3) + security (= 0.1.5) simctl (~> 1.6.3) terminal-notifier (>= 2.0.0, < 3.0.0) terminal-table (~> 3) @@ -105,11 +109,13 @@ GEM word_wrap (~> 1.0.0) xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) - xcpretty-travis-formatter (>= 0.0.3) + xcpretty-travis-formatter (>= 0.0.3, < 2.0.0) + fastlane-sirp (1.0.0) + sysrandom (~> 1.0) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.51.0) + google-apis-androidpublisher_v3 (0.54.0) google-apis-core (>= 0.11.0, < 2.a) - google-apis-core (0.11.2) + google-apis-core (0.11.3) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -117,24 +123,23 @@ GEM representable (~> 3.0) retriable (>= 2.0, < 4.a) rexml - webrick google-apis-iamcredentials_v1 (0.17.0) google-apis-core (>= 0.11.0, < 2.a) google-apis-playcustomapp_v1 (0.13.0) google-apis-core (>= 0.11.0, < 2.a) - google-apis-storage_v1 (0.19.0) - google-apis-core (>= 0.9.0, < 2.a) - google-cloud-core (1.6.0) - google-cloud-env (~> 1.0) + google-apis-storage_v1 (0.31.0) + google-apis-core (>= 0.11.0, < 2.a) + google-cloud-core (1.7.1) + google-cloud-env (>= 1.0, < 3.a) google-cloud-errors (~> 1.0) google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) - google-cloud-errors (1.3.1) - google-cloud-storage (1.44.0) + google-cloud-errors (1.4.0) + google-cloud-storage (1.47.0) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-iamcredentials_v1 (~> 0.1) - google-apis-storage_v1 (~> 0.19.0) + google-apis-storage_v1 (~> 0.31.0) google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) @@ -145,34 +150,36 @@ GEM os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) highline (2.0.3) - http-cookie (1.0.5) + http-cookie (1.0.7) domain_name (~> 0.5) httpclient (2.8.3) jmespath (1.6.2) - json (2.6.3) - jwt (2.7.1) - mini_magick (4.12.0) + json (2.7.3) + jwt (2.9.3) + base64 + mini_magick (4.13.2) mini_mime (1.1.5) multi_json (1.15.0) - multipart-post (2.3.0) + multipart-post (2.4.1) nanaimo (0.3.0) naturally (2.2.1) - optparse (0.1.1) + nkf (0.2.0) + optparse (0.5.0) os (1.1.4) - plist (3.7.0) - public_suffix (5.0.3) - rake (13.1.0) + plist (3.7.1) + public_suffix (6.0.1) + rake (13.2.1) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.2.6) + rexml (3.3.9) rouge (2.0.7) ruby2_keywords (0.0.5) rubyzip (2.3.2) - security (0.1.3) - signet (0.18.0) + security (0.1.5) + signet (0.19.0) addressable (~> 2.8) faraday (>= 0.17.5, < 3.a) jwt (>= 1.5, < 3.0) @@ -180,28 +187,25 @@ GEM simctl (1.6.10) CFPropertyList naturally + sysrandom (1.0.5) terminal-notifier (2.0.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) trailblazer-option (0.1.2) tty-cursor (0.7.1) - tty-screen (0.8.1) + tty-screen (0.8.2) tty-spinner (0.9.3) tty-cursor (~> 0.7) uber (0.1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) - unicode-display_width (2.5.0) - webrick (1.8.1) + unicode-display_width (2.6.0) word_wrap (1.0.0) - xcodeproj (1.23.0) + xcodeproj (1.25.1) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) - rexml (~> 3.2.4) + rexml (>= 3.3.6, < 4.0) xcpretty (0.3.0) rouge (~> 2.0.7) xcpretty-travis-formatter (1.0.1) diff --git a/src/components/Permitted.tsx b/src/components/Permitted.tsx index e6337c362..c4ae54f9b 100644 --- a/src/components/Permitted.tsx +++ b/src/components/Permitted.tsx @@ -39,6 +39,7 @@ import { isJapanese, translate } from '../translation' import { isDevApp } from '../utils/isDevApp' import DevOverlay from './DevOverlay' import Header from './Header' +import Loading from './Loading' import NewReportModal from './NewReportModal' import WarningPanel from './WarningPanel' @@ -89,7 +90,8 @@ const PermittedLayout: React.FC = ({ children }: Props) => { useAndroidWearable() useUpdateLiveActivities() useListenMessaging() - useDeepLink() + const { isLoading: isRoutesLoadingByLink, error: fetchRoutesByLinkError } = + useDeepLink() const user = useCachedInitAnonymousUser() const currentLine = useCurrentLine() @@ -103,73 +105,148 @@ const PermittedLayout: React.FC = ({ children }: Props) => { const viewShotRef = useRef(null) - const onLongPress = async ({ - nativeEvent, - }: { - nativeEvent: { - state: State + const handleReport = useCallback(async () => { + if (!viewShotRef.current?.capture) { + return + } + + try { + switch (reportEligibility) { + case 'banned': + Alert.alert(translate('errorTitle'), translate('feedbackBanned')) + return + case 'limitExceeded': + Alert.alert( + translate('annoucementTitle'), + translate('feedbackSendLimitExceeded') + ) + return + default: + break + } + + const uri = await viewShotRef.current.capture() + setScreenShotBase64(await RNFS.readFile(uri, 'base64')) + + setReportModalShow(true) + } catch (err) { + console.error(err) + Alert.alert(translate('errorTitle'), translate('reportError')) } - }): Promise => { - if (!selectedBound || nativeEvent.state !== State.ACTIVE) { + }, [reportEligibility]) + + const handleShare = useCallback(async () => { + if (!viewShotRef || !currentLine) { return } + try { + if (!viewShotRef.current?.capture || !currentLine) { + return + } - await Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium) + const uri = await viewShotRef.current.capture() + const res = await RNFS.readFile(uri, 'base64') + const urlString = `data:image/jpeg;base64,${res}` + const message = isJapanese + ? `${currentLine.nameShort.replace( + parenthesisRegexp, + '' + )}で移動中です! #TrainLCD https://trainlcd.app` + : `I'm riding ${currentLine.nameRoman?.replace( + parenthesisRegexp, + '' + )} with #TrainLCD https://trainlcd.app` + const options = { + title: 'TrainLCD', + message, + url: urlString, + type: 'image/png', + } + await Share.open(options) + } catch (err) { + if ((err as { message: string }).message !== 'User did not share') { + Alert.alert(`${translate('couldntShare')} ${err}`) + } + } + }, [currentLine]) - const buttons = Platform.select({ - ios: [ - translate('back'), - translate('share'), - translate('report'), - translate('cancel'), - ], - android: [translate('share'), translate('report'), translate('cancel')], - }) + const onLongPress = useCallback( + async ({ + nativeEvent, + }: { + nativeEvent: { + state: State + } + }): Promise => { + if (!selectedBound || nativeEvent.state !== State.ACTIVE) { + return + } - showActionSheetWithOptions( - { - options: buttons || [], - destructiveButtonIndex: Platform.OS === 'ios' ? 0 : undefined, - cancelButtonIndex: buttons && buttons.length - 1, - }, - (buttonIndex) => { - switch (buttonIndex) { - // iOS: back, Android: share - case 0: - if (Platform.OS === 'ios') { - navigation.navigate('SelectBound') - resetMainState() - break - } - handleShare() - break - // iOS: share, Android: feedback - case 1: - if (Platform.OS === 'ios') { + await Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium) + + const buttons = Platform.select({ + ios: [ + translate('back'), + translate('share'), + translate('report'), + translate('cancel'), + ], + android: [translate('share'), translate('report'), translate('cancel')], + }) + + showActionSheetWithOptions( + { + options: buttons || [], + destructiveButtonIndex: Platform.OS === 'ios' ? 0 : undefined, + cancelButtonIndex: buttons && buttons.length - 1, + }, + (buttonIndex) => { + switch (buttonIndex) { + // iOS: back, Android: share + case 0: + if (Platform.OS === 'ios') { + navigation.navigate('SelectBound') + resetMainState() + break + } handleShare() break - } - handleReport() - break - // iOS: feedback, Android: cancel - case 2: { - if (Platform.OS === 'ios') { + // iOS: share, Android: feedback + case 1: + if (Platform.OS === 'ios') { + handleShare() + break + } handleReport() break + // iOS: feedback, Android: cancel + case 2: { + if (Platform.OS === 'ios') { + handleReport() + break + } + break } - break - } - // iOS: cancel, Android: will be not passed here - case 3: { - break + // iOS: cancel, Android: will be not passed here + case 3: { + break + } + // iOS, Android: will be not passed here + default: + break } - // iOS, Android: will be not passed here - default: - break } - } - ) - } + ) + }, + [ + handleReport, + handleShare, + navigation, + resetMainState, + selectedBound, + showActionSheetWithOptions, + ] + ) useEffect(() => { const loadSettingsAsync = async () => { @@ -245,6 +322,13 @@ const PermittedLayout: React.FC = ({ children }: Props) => { return remove }, [selectedBound]) + useEffect(() => { + if (fetchRoutesByLinkError) { + console.error(fetchRoutesByLinkError) + Alert.alert(translate('errorTitle'), translate('failedToFetchStation')) + } + }, [fetchRoutesByLinkError]) + const getWarningInfo = useCallback(() => { if (warningDismissed) { return null @@ -327,76 +411,11 @@ const PermittedLayout: React.FC = ({ children }: Props) => { [onWarningPress, warningInfo] ) - const handleShare = useCallback(async () => { - if (!viewShotRef || !currentLine) { - return - } - try { - if (!viewShotRef.current?.capture || !currentLine) { - return - } - - const uri = await viewShotRef.current.capture() - const res = await RNFS.readFile(uri, 'base64') - const urlString = `data:image/jpeg;base64,${res}` - const message = isJapanese - ? `${currentLine.nameShort.replace( - parenthesisRegexp, - '' - )}で移動中です! #TrainLCD https://trainlcd.app` - : `I'm riding ${currentLine.nameRoman?.replace( - parenthesisRegexp, - '' - )} with #TrainLCD https://trainlcd.app` - const options = { - title: 'TrainLCD', - message, - url: urlString, - type: 'image/png', - } - await Share.open(options) - } catch (err) { - if ((err as { message: string }).message !== 'User did not share') { - Alert.alert(`${translate('couldntShare')} ${err}`) - } - } - }, [currentLine]) - - const handleReport = async () => { - if (!viewShotRef.current?.capture) { - return - } - - try { - switch (reportEligibility) { - case 'banned': - Alert.alert(translate('errorTitle'), translate('feedbackBanned')) - return - case 'limitExceeded': - Alert.alert( - translate('annoucementTitle'), - translate('feedbackSendLimitExceeded') - ) - return - default: - break - } - - const uri = await viewShotRef.current.capture() - setScreenShotBase64(await RNFS.readFile(uri, 'base64')) - - setReportModalShow(true) - } catch (err) { - console.error(err) - Alert.alert(translate('errorTitle'), translate('reportError')) - } - } - - const handleNewReportModalClose = () => { + const handleNewReportModalClose = useCallback(() => { setReportDescription('') setScreenShotBase64('') setReportModalShow(false) - } + }, []) const handleReportSend = useCallback(() => { if (reportDescription.length < descriptionLowerLimit) { @@ -439,7 +458,17 @@ const PermittedLayout: React.FC = ({ children }: Props) => { style: 'cancel', }, ]) - }, [descriptionLowerLimit, reportDescription, screenShotBase64, sendReport]) + }, [ + descriptionLowerLimit, + handleNewReportModalClose, + reportDescription, + screenShotBase64, + sendReport, + ]) + + if (isRoutesLoadingByLink && !fetchRoutesByLinkError) { + return + } return ( diff --git a/src/hooks/useDeepLink.ts b/src/hooks/useDeepLink.ts index b9880edab..62fa724f2 100644 --- a/src/hooks/useDeepLink.ts +++ b/src/hooks/useDeepLink.ts @@ -3,7 +3,7 @@ import { useCallback, useEffect } from 'react' import { useOpenRouteFromLink } from './useOpenRouteFromLink' export const useDeepLink = () => { - const { openLink: openRoute } = useOpenRouteFromLink() + const { openLink: openRoute, isLoading, error } = useOpenRouteFromLink() const handleParsedUrl = useCallback( async (parsedUrl: Linking.ParsedURL) => { @@ -54,4 +54,6 @@ export const useDeepLink = () => { listener.remove() } }, [handleParsedUrl, handleUrl]) + + return { isLoading, error } }