Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
simplify progress dialog checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tanersener committed Aug 22, 2022
1 parent f499bf9 commit 7d0f012
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 60 deletions.
12 changes: 5 additions & 7 deletions react-native/test-app-local-dependency/src/pipe-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,14 @@ export default class PipeTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.time;
if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
}
let timeInMilliseconds = statistics.getTime();
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
}

hideProgressDialog() {
Expand Down
12 changes: 5 additions & 7 deletions react-native/test-app-local-dependency/src/saf-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,14 @@ export default class SafTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.time;
if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}
let timeInMilliseconds = statistics.getTime();
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}

hideProgressDialog() {
Expand Down
18 changes: 8 additions & 10 deletions react-native/test-app-local-dependency/src/subtitle-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,18 @@ export default class SubtitleTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.time;
if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
let timeInMilliseconds = statistics.getTime();
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);

if (this.state.state === 'CREATING') {
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
} else if (this.state.state === 'BURNING') {
this.progressModalReference.current.update(`Burning subtitles % ${completePercentage}`);
}
if (this.state.state === 'CREATING') {
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
} else if (this.state.state === 'BURNING') {
this.progressModalReference.current.update(`Burning subtitles % ${completePercentage}`);
}
}

Expand Down
10 changes: 4 additions & 6 deletions react-native/test-app-local-dependency/src/video-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,15 @@ export default class VideoTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.getTime();

if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}

hideProgressDialog() {
Expand Down
12 changes: 5 additions & 7 deletions react-native/test-app-npm/src/pipe-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,14 @@ export default class PipeTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.time;
if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
}
let timeInMilliseconds = statistics.getTime();
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
}

hideProgressDialog() {
Expand Down
12 changes: 5 additions & 7 deletions react-native/test-app-npm/src/saf-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,14 @@ export default class SafTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.time;
if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}
let timeInMilliseconds = statistics.getTime();
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}

hideProgressDialog() {
Expand Down
18 changes: 8 additions & 10 deletions react-native/test-app-npm/src/subtitle-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,18 @@ export default class SubtitleTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.time;
if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
let timeInMilliseconds = statistics.getTime();
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);

if (this.state.state === 'CREATING') {
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
} else if (this.state.state === 'BURNING') {
this.progressModalReference.current.update(`Burning subtitles % ${completePercentage}`);
}
if (this.state.state === 'CREATING') {
this.progressModalReference.current.update(`Creating video % ${completePercentage}`);
} else if (this.state.state === 'BURNING') {
this.progressModalReference.current.update(`Burning subtitles % ${completePercentage}`);
}
}

Expand Down
10 changes: 4 additions & 6 deletions react-native/test-app-npm/src/video-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,15 @@ export default class VideoTab extends React.Component {

updateProgressDialog() {
let statistics = this.state.statistics;
if (statistics === undefined) {
if (statistics === undefined || statistics.getTime() < 0) {
return;
}

let timeInMilliseconds = statistics.getTime();

if (timeInMilliseconds > 0) {
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}
let totalVideoDuration = 9000;
let completePercentage = Math.round((timeInMilliseconds * 100) / totalVideoDuration);
this.progressModalReference.current.update(`Encoding video % ${completePercentage}`);
}

hideProgressDialog() {
Expand Down

0 comments on commit 7d0f012

Please sign in to comment.