chore: upgrade mobile dependencies (#2578)

This commit is contained in:
Aman Harwara
2023-10-13 14:56:21 +05:30
committed by GitHub
parent 6c137bfdf1
commit 442bb988ef
49 changed files with 235 additions and 449 deletions

View File

@@ -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)

View 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())
}
}