Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assisted server backup tier restriction #6086

Open
wants to merge 4 commits into
base: sprint
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/hooks/useSettingKeeper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ import ToastErrorIcon from 'src/assets/images/toast_error.svg';
import { setThemeMode } from 'src/store/reducers/settings';
import ThemeMode from 'src/models/enums/ThemeMode';
import { credsAuthenticated } from 'src/store/reducers/login';
import usePlan from './usePlan';

export const useSettingKeeper = () => {
const dispatch = useAppDispatch();
const { colorMode, toggleColorMode } = useColorMode();
const navigation = useNavigation();
const { showToast } = useToastMessage();
const isFocused = useIsFocused();
const { isOnL2Above, isOnL3 } = usePlan();

const data = useQuery(RealmSchema.BackupHistory);
const [confirmPass, setConfirmPass] = useState(false);
Expand Down Expand Up @@ -165,7 +167,7 @@ export const useSettingKeeper = () => {
description: inheritancePlanning.personalCloudDescp,
icon: <CloudIcon width={16} height={12} />,
onRightPress: () => navigation.navigate('ChoosePlan'),
rightIcon: <UpgradeIcon width={64} height={20} />,
rightIcon: isOnL2Above ? null : <UpgradeIcon width={64} height={20} />,
onPress: () => navigation.navigate('CloudBackup'),
isDiamond: true,
isHodler: true,
Expand All @@ -176,10 +178,16 @@ export const useSettingKeeper = () => {
description: settings.assistedServerBackupSubtitle,
icon: <CloudBackupIcon width={14} height={14} />,
onPress: () => {},
rightIcon: <Switch onValueChange={() => {}} value={automaticCloudBackup} />,
onRightPress: toggleDebounce(() => toggleAutomaticBackupMode()),
rightIcon: isOnL2Above ? (
<Switch onValueChange={() => {}} value={automaticCloudBackup} />
) : (
<UpgradeIcon width={64} height={20} />
),
onRightPress: isOnL2Above
? toggleDebounce(() => toggleAutomaticBackupMode())
: () => navigation.navigate('ChoosePlan'),
isDiamond: false,
isHodler: false,
isHodler: true,
},
];

Expand Down Expand Up @@ -233,7 +241,7 @@ export const useSettingKeeper = () => {
title: vault.canaryWallet,
description: inheritancePlanning.canaryWalletDesp,
icon: <CanaryIcon width={14} height={14} />,
rightIcon: <UpgradeIcon width={64} height={20} />,
rightIcon: isOnL3 ? null : <UpgradeIcon width={64} height={20} />,
onRightPress: () => navigation.navigate('ChoosePlan'),

onPress: () => navigation.navigate('CanaryWallets'),
Expand Down
3 changes: 3 additions & 0 deletions src/screens/ChoosePlanScreen/ChoosePlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import WalletHeader from 'src/components/WalletHeader';
import SubscriptionList from './components/SubscriptionList';
import usePlan from 'src/hooks/usePlan';
import { setSubscription } from 'src/store/reducers/settings';
import { setAutomaticCloudBackup } from 'src/store/reducers/bhr';
import { AppSubscriptionLevel } from 'src/models/enums/SubscriptionTier';
const { width } = Dimensions.get('window');

const OLD_SUBS_PRODUCT_ID = ['hodler.dev', 'diamond_hands.dev', 'diamond_hands', 'hodler'];
Expand Down Expand Up @@ -292,6 +294,7 @@ function ChoosePlan() {
dbManager.updateObjectById(RealmSchema.KeeperApp, id, {
subscription: updatedSubscription,
});
if (response.level === AppSubscriptionLevel.L1) disptach(setAutomaticCloudBackup(false));
disptach(setSubscription(subscription.name));
disptach(uaiChecks([uaiType.VAULT_MIGRATION]));
// disptach(resetVaultMigration());
Expand Down
13 changes: 1 addition & 12 deletions src/screens/Home/components/Settings/Component/SettingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,7 @@ const SettingCard: React.FC<SettingCardProps> = ({
onPress={item.onRightPress}
testID={`btn_right_${item.title}`}
>
<Box>
{(item?.isDiamond && isDiamondHands) || (item?.isHodler && isHodler) ? (
isDarkMode ? (
<WhiteRightArrowIcon />
) : (
<RightArrowIcon />
)
) : (
item.rightIcon
)}
</Box>
<Box>{item.rightIcon}</Box>
</TouchableOpacity>
) : (
<Box>{isDarkMode ? <WhiteRightArrowIcon /> : <RightArrowIcon />}</Box>
Expand Down Expand Up @@ -196,7 +186,6 @@ const styles = StyleSheet.create({
marginRight: wp(6),
},
rightIcon: {
width: 40,
justifyContent: 'center',
alignItems: 'flex-end',
},
Expand Down
3 changes: 3 additions & 0 deletions src/screens/LoginScreen/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { fetchOneDayInsight } from 'src/store/sagaActions/send_and_receive';
import { PasswordTimeout } from 'src/utils/PasswordTimeout';
import Buttons from 'src/components/Buttons';
import PinDotView from 'src/components/AppPinInput/PinDotView';
import { setAutomaticCloudBackup } from 'src/store/reducers/bhr';

const TIMEOUT = 60;
const RNBiometrics = new ReactNativeBiometrics();
Expand Down Expand Up @@ -401,6 +402,8 @@ function LoginScreen({ navigation, route }) {
});
dispatch(setSubscription(updatedSubscription.name));
dispatch(setOfflineStatus(true));
// disable assisted server backup for pleb
dispatch(setAutomaticCloudBackup(false));
navigation.replace('App');
}

Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/bhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const initialState: {

pendingAllBackup: false,

automaticCloudBackup: true,
automaticCloudBackup: false,
};

const bhrSlice = createSlice({
Expand Down
6 changes: 6 additions & 0 deletions src/store/sagas/bhr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
setAppImageError,
setAppImageRecoverd,
setAppRecoveryLoading,
setAutomaticCloudBackup,
setBackupAllFailure,
setBackupAllLoading,
setBackupAllSuccess,
Expand Down Expand Up @@ -1011,6 +1012,11 @@ export const backupAllSignersAndVaultsWatcher = createWatcher(

export function* checkBackupCondition() {
const { pendingAllBackup, automaticCloudBackup } = yield select((state: RootState) => state.bhr);
const { subscription }: KeeperApp = yield call(dbManager.getObjectByIndex, RealmSchema.KeeperApp);
if (automaticCloudBackup && subscription.level === AppSubscriptionLevel.L1) {
yield put(setAutomaticCloudBackup(false));
return true;
}
if (!automaticCloudBackup) return true;
const netInfo = yield call(NetInfo.fetch);
if (!netInfo.isConnected) {
Expand Down
2 changes: 2 additions & 0 deletions src/store/sagas/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { resetSyncing } from '../reducers/wallets';
import { connectToNode } from '../sagaActions/network';
import SubScription from 'src/models/interfaces/Subscription';
import { AppSubscriptionLevel, SubscriptionTier } from 'src/models/enums/SubscriptionTier';
import { setAutomaticCloudBackup } from '../reducers/bhr';

export const stringToArrayBuffer = (byteString: string): Uint8Array => {
if (byteString) {
Expand Down Expand Up @@ -245,6 +246,7 @@ async function downgradeToPleb() {
subscription: updatedSubscription,
});
store.dispatch(setSubscription(updatedSubscription.name));
store.dispatch(setAutomaticCloudBackup(false));
await Relay.updateSubscription(app.id, app.publicId, {
productId: SubscriptionTier.L1.toLowerCase(),
});
Expand Down
Loading