chore: upgrade mobile dependencies (#2578)
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
"@babel/core": "*",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@babel/runtime": "^7.20.1",
|
||||
"@react-native-async-storage/async-storage": "1.19.2",
|
||||
"@react-native-async-storage/async-storage": "1.19.3",
|
||||
"@react-native/eslint-config": "^0.72.2",
|
||||
"@react-native/metro-config": "^0.72.11",
|
||||
"@standardnotes/config": "^2.4.3",
|
||||
@@ -39,8 +39,8 @@
|
||||
"@standardnotes/snjs": "workspace:*",
|
||||
"@standardnotes/web": "workspace:*",
|
||||
"@tsconfig/react-native": "^3.0.2",
|
||||
"@types/react": "^18.0.25",
|
||||
"@types/react-native": "^0.72.2",
|
||||
"@types/react": "^18.2.28",
|
||||
"@types/react-native": "^0.72.3",
|
||||
"@typescript-eslint/eslint-plugin": "*",
|
||||
"@typescript-eslint/parser": "*",
|
||||
"babel-jest": "^29.3.1",
|
||||
@@ -48,13 +48,13 @@
|
||||
"eslint": "*",
|
||||
"eslint-plugin-prettier": "*",
|
||||
"get-yarn-workspaces": "^1.0.2",
|
||||
"metro-react-native-babel-preset": "^0.76.8",
|
||||
"metro-react-native-babel-preset": "^0.77.0",
|
||||
"npm-check-updates": "*",
|
||||
"pod-install": "^0.1.38",
|
||||
"prettier": "*",
|
||||
"prettier-plugin-organize-imports": "^3.2.0",
|
||||
"react": "18.2.0",
|
||||
"react-native": "0.72.4",
|
||||
"react-native": "0.72.5",
|
||||
"react-native-file-viewer": "^2.1.5",
|
||||
"react-native-fingerprint-scanner": "standardnotes/react-native-fingerprint-scanner#b55d1c0ca627a87a130f758603f12911fbac200f",
|
||||
"react-native-flag-secure-android": "standardnotes/react-native-flag-secure-android#cb08e74583c22a5d912842459b35ebbbb4bcd852",
|
||||
@@ -63,12 +63,15 @@
|
||||
"react-native-keychain": "standardnotes/react-native-keychain#4fd687461cecfa26d482d820ee43c0de61b964d4",
|
||||
"react-native-mmkv": "^2.6.2",
|
||||
"react-native-privacy-snapshot": "standardnotes/react-native-privacy-snapshot#653e904c90fc6f2b578da59138f2bfe5d7f942fe",
|
||||
"react-native-share": "^9.2.3",
|
||||
"react-native-share": "^9.4.1",
|
||||
"react-native-version-info": "^1.1.1",
|
||||
"react-native-webview": "13.3.1",
|
||||
"typescript": "^4.9.3"
|
||||
"react-native-webview": "13.6.0",
|
||||
"typescript": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-native-store-review": "^0.4.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import CustomAndroidWebView from './CustomAndroidWebView'
|
||||
import { MobileDevice, MobileDeviceEvent } from './Lib/MobileDevice'
|
||||
import { IsDev } from './Lib/Utils'
|
||||
import { ReceivedSharedItemsHandler } from './ReceivedSharedItemsHandler'
|
||||
import { ReviewService } from './ReviewService'
|
||||
|
||||
const LoggingEnabled = IsDev
|
||||
|
||||
@@ -37,6 +38,7 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
|
||||
() => new MobileDevice(stateService, androidBackHandlerService, colorSchemeService),
|
||||
[androidBackHandlerService, colorSchemeService, stateService],
|
||||
)
|
||||
const _reviewService = useRef(new ReviewService(device))
|
||||
|
||||
const [showAndroidWebviewUpdatePrompt, setShowAndroidWebviewUpdatePrompt] = useState(false)
|
||||
|
||||
|
||||
34
packages/mobile/src/ReviewService.ts
Normal file
34
packages/mobile/src/ReviewService.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ApplicationEvent } from '@standardnotes/snjs'
|
||||
import { MobileDevice } from 'Lib/MobileDevice'
|
||||
import * as StoreReview from 'react-native-store-review'
|
||||
|
||||
const RUN_COUNTS_BEFORE_REVIEW = [18, 45, 105]
|
||||
|
||||
export class ReviewService {
|
||||
constructor(private device: MobileDevice) {
|
||||
this.device.addApplicationEventReceiver(this.onApplicationEvent.bind(this))
|
||||
}
|
||||
async onApplicationEvent(event: ApplicationEvent) {
|
||||
if (event !== ApplicationEvent.Launched) {
|
||||
return
|
||||
}
|
||||
const runCount = await this.getRunCount()
|
||||
void this.setRunCount(runCount + 1)
|
||||
if (RUN_COUNTS_BEFORE_REVIEW.includes(runCount)) {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
StoreReview.requestReview()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
async getRunCount() {
|
||||
const value = await this.device.getJsonParsedRawStorageValue('runCount')
|
||||
return Number(value) || 0
|
||||
}
|
||||
async setRunCount(runCount: number) {
|
||||
return this.device.setRawStorageValue('runCount', runCount.toString())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user