Skip to content

Commit

Permalink
Merge pull request #272 from juanky201271/dev_background_to_foregroun…
Browse files Browse the repository at this point in the history
…d_report_screen_blocks_fixed

Sync Report screen with wrong data when come back from the background - FIXED
  • Loading branch information
zancas authored Apr 14, 2023
2 parents e81923f + 80aa702 commit 9f4838a
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 275 deletions.
1 change: 1 addition & 0 deletions __tests__/__snapshots__/History.snapshot.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ exports[`Component Transactions - test Transactions - snapshot 1`] = `
"opacity": 1,
}
}
testID="header.drawmenu"
>
<
color="rgb(216, 216, 216)"
Expand Down
160 changes: 10 additions & 150 deletions __tests__/__snapshots__/SyncReport.snapshot.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ exports[`Component SyncReport - test Matches the snapshot SyncReport 1`] = `
<View
style={
{
"backgroundColor": "transparent",
"backgroundColor": "#333333",
"borderRightColor": "rgb(0, 122, 255)",
"borderRightWidth": 1,
"height": 10,
Expand Down Expand Up @@ -566,7 +566,7 @@ exports[`Component SyncReport - test Matches the snapshot SyncReport 1`] = `
"borderRightColor": "rgb(0, 122, 255)",
"borderRightWidth": 1,
"height": 10,
"width": "25.00006250015625%",
"width": "25.000062500156254%",
}
}
/>
Expand Down Expand Up @@ -655,6 +655,7 @@ exports[`Component SyncReport - test Matches the snapshot SyncReport 1`] = `
"color": "rgb(28, 28, 30)",
}
}
testID="syncreport.syncednow"
>
200000translated text50.00%
</Text>
Expand Down Expand Up @@ -699,6 +700,7 @@ exports[`Component SyncReport - test Matches the snapshot SyncReport 1`] = `
"color": "rgb(28, 28, 30)",
}
}
testID="syncreport.notyetsynced"
>
100000translated text25.00%
</Text>
Expand Down Expand Up @@ -747,6 +749,7 @@ exports[`Component SyncReport - test Matches the snapshot SyncReport 1`] = `
"opacity": 1,
}
}
testID="syncreport.currentbatch"
>
translated text5translated text50
</Text>
Expand Down Expand Up @@ -785,6 +788,7 @@ exports[`Component SyncReport - test Matches the snapshot SyncReport 1`] = `
"opacity": 1,
}
}
testID="syncreport.blocksperbatch"
>
100
</Text>
Expand Down Expand Up @@ -835,154 +839,10 @@ exports[`Component SyncReport - test Matches the snapshot SyncReport 1`] = `
122
</Text>
</View>
<View
style={
{
"margin": 10,
}
}
>
<RNSVGSvgView
bbHeight="20"
bbWidth="20"
focusable={false}
height={20}
style={
[
{
"backgroundColor": "transparent",
"borderWidth": 0,
},
{
"flex": 0,
"height": 20,
"width": 20,
},
]
}
width={20}
>
<RNSVGGroup
fill={
{
"payload": 4278190080,
"type": 0,
}
}
>
<RNSVGCircle
cx="10"
cy="10"
fill={null}
propList={
[
"fill",
"stroke",
"strokeWidth",
]
}
r="9.5"
stroke={
{
"payload": 4294967295,
"type": 0,
}
}
strokeWidth="1"
/>
<RNSVGCircle
cx="10"
cy="10"
fill={null}
matrix={
[
6.123233995736766e-17,
-1,
1,
6.123233995736766e-17,
0,
20,
]
}
propList={
[
"fill",
"stroke",
"strokeWidth",
"strokeDasharray",
"strokeDashoffset",
"strokeLinecap",
]
}
r="9.5"
stroke={
{
"payload": 4278221567,
"type": 0,
}
}
strokeDasharray={
[
"59.690260418206066",
"59.690260418206066",
]
}
strokeDashoffset={47.752208334564855}
strokeLinecap={1}
strokeWidth="1"
/>
<RNSVGText
content={null}
dx={[]}
dy={[]}
fill={
{
"payload": 4280032286,
"type": 0,
}
}
font={
{
"fontSize": "12",
"textAnchor": "middle",
}
}
propList={
[
"fill",
]
}
rotate={[]}
x={
[
"10",
]
}
y={
[
"15",
]
}
>
<RNSVGTSpan
content=""
dx={[]}
dy={[]}
fill={
{
"payload": 4278190080,
"type": 0,
}
}
font={{}}
rotate={[]}
x={[]}
y={[]}
/>
</RNSVGText>
</RNSVGGroup>
</RNSVGSvgView>
</View>
<ActivityIndicator
color="rgb(0, 122, 255)"
size="large"
/>
</View>
<View
style={
Expand Down
2 changes: 1 addition & 1 deletion app/LoadedApp/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Menu: React.FunctionComponent<MenuProps> = ({ onItemSelected }) => {
{translate('loadedapp.rescanwallet') as string}
</RegText>

<RegText onPress={() => onItemSelectedWrapper('Sync Report')} style={item}>
<RegText testID="menu.syncreport" onPress={() => onItemSelectedWrapper('Sync Report')} style={item}>
{translate('loadedapp.report') as string}
</RegText>

Expand Down
15 changes: 7 additions & 8 deletions app/rpc/RPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export default class RPC {
seconds_batch: number;
batches: number;
message: string;
process_end_block: number;

constructor(
fnSetSyncingStatusReport: (syncingStatusReport: SyncingStatusReportClass) => void,
Expand Down Expand Up @@ -93,7 +92,6 @@ export default class RPC {
this.seconds_batch = 0;
this.batches = 0;
this.message = '';
this.process_end_block = -1;
}

static async rpc_setInterruptSyncAfterBatch(value: string): Promise<void> {
Expand Down Expand Up @@ -505,7 +503,6 @@ export default class RPC {
this.seconds_batch = 0;
this.batches = 0;
this.message = this.translate('rpc.syncstart-message') as string;
this.process_end_block = fullRescan ? this.walletBirthday : this.lastWalletBlockHeight;

// This is async, so when it is done, we finish the refresh.
if (fullRescan) {
Expand Down Expand Up @@ -551,7 +548,6 @@ export default class RPC {
this.seconds_batch = 0;
this.batches = 0;
this.message = this.translate('rpc.syncstart-message') as string;
this.process_end_block = this.lastWalletBlockHeight;
}
this.prev_sync_id = ss.sync_id;
}
Expand Down Expand Up @@ -593,7 +589,10 @@ export default class RPC {

const end_block: number = ss.end_block || 0; // lower

const total_general_blocks: number = this.lastServerBlockHeight - this.process_end_block;
// I want to know what was the first block of the current sync process
const process_end_block = end_block - batch_num * this.blocksPerBatch;

const total_general_blocks: number = this.lastServerBlockHeight - process_end_block;

//const progress_blocks: number = (synced_blocks + trial_decryptions_blocks + txn_scan_blocks) / 3;
const progress_blocks: number = (synced_blocks + trial_decryptions_blocks + witnesses_updated) / 3;
Expand Down Expand Up @@ -654,7 +653,7 @@ export default class RPC {
secondsPerBatch: this.seconds_batch,
percent: progress,
message: this.message,
process_end_block: this.process_end_block,
process_end_block: process_end_block,
lastBlockServer: this.lastServerBlockHeight,
};
this.fnSetSyncingStatusReport(statusGeneral);
Expand Down Expand Up @@ -735,7 +734,7 @@ export default class RPC {
secondsPerBatch: this.seconds_batch,
percent: progress,
message: this.message,
process_end_block: this.process_end_block,
process_end_block: process_end_block,
lastBlockServer: this.lastServerBlockHeight,
};
this.fnSetSyncingStatusReport(statusBatch);
Expand Down Expand Up @@ -774,7 +773,7 @@ export default class RPC {
secondsPerBatch: this.seconds_batch,
percent: progress,
message: this.message,
process_end_block: this.process_end_block,
process_end_block: process_end_block,
lastBlockServer: this.lastServerBlockHeight,
};
this.fnSetSyncingStatusReport(statusSeconds);
Expand Down
9 changes: 7 additions & 2 deletions components/Components/DetailLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ type DetailLineProps = {
label: string;
value?: string;
children?: ReactNode;
testID?: string;
};

const DetailLine: React.FunctionComponent<DetailLineProps> = ({ label, value, children }) => {
const DetailLine: React.FunctionComponent<DetailLineProps> = ({ label, value, children, testID }) => {
const { colors } = useTheme() as unknown as ThemeType;
return (
<View style={{ display: 'flex', marginTop: 20 }}>
<FadeText>{label}</FadeText>
<View style={{ width: 10 }} />
{value && <RegText color={colors.text}>{value}</RegText>}
{value && (
<RegText testID={testID} color={colors.text}>
{value}
</RegText>
)}
{children}
</View>
);
Expand Down
1 change: 1 addition & 0 deletions components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const Header: React.FunctionComponent<HeaderProps> = ({
{!noDrawMenu && (
<View style={{ backgroundColor: colors.card, padding: 10, position: 'absolute', left: 0 }}>
<TouchableOpacity
testID="header.drawmenu"
accessible={true}
accessibilityLabel={translate('menudrawer-acc') as string}
onPress={toggleMenuDrawer}>
Expand Down
Loading

0 comments on commit 9f4838a

Please sign in to comment.