forked from Ivasoft/mattermost-mobile
* Add app review * Use overlay instead of modal * Add fixes for ios * i18n-extract * Add to milliseconds function * Address review feedback * Add try to queryGlobalValue * added app review illustration * add feedback illustration * Add animations and feedback bot message * Restrict reviews to build environment variable * Fix bug with "dont ask anymore" * Add check for only supported servers * Add missing change * Use for await Co-authored-by: Daniel Espino <danielespino@MacBook-Pro-de-Daniel.local> Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import InAppReview from 'react-native-in-app-review';
|
|
|
|
import {storeFirstLaunch} from '@actions/app/global';
|
|
import LocalConfig from '@assets/config.json';
|
|
import {General, Launch} from '@constants';
|
|
import {getDontAskForReview, getFirstLaunch, getLastAskedForReview} from '@queries/app/global';
|
|
import {areAllServersSupported} from '@queries/app/servers';
|
|
import {showReviewOverlay} from '@screens/navigation';
|
|
|
|
export const tryRunAppReview = async (launchType: string, coldStart?: boolean) => {
|
|
if (!LocalConfig.ShowReview) {
|
|
return;
|
|
}
|
|
|
|
if (!coldStart) {
|
|
return;
|
|
}
|
|
|
|
if (launchType !== Launch.Normal) {
|
|
return;
|
|
}
|
|
|
|
if (!InAppReview.isAvailable()) {
|
|
return;
|
|
}
|
|
|
|
const supported = await areAllServersSupported();
|
|
if (!supported) {
|
|
return;
|
|
}
|
|
|
|
const dontAsk = await getDontAskForReview();
|
|
if (dontAsk) {
|
|
return;
|
|
}
|
|
|
|
const lastReviewed = await getLastAskedForReview();
|
|
if (lastReviewed) {
|
|
if (Date.now() - lastReviewed > General.TIME_TO_NEXT_REVIEW) {
|
|
showReviewOverlay(true);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
const firstLaunch = await getFirstLaunch();
|
|
if (!firstLaunch) {
|
|
storeFirstLaunch();
|
|
return;
|
|
}
|
|
|
|
if ((Date.now() - firstLaunch) > General.TIME_TO_FIRST_REVIEW) {
|
|
showReviewOverlay(false);
|
|
}
|
|
};
|