Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Last couple fixes on the Android side: the open/save dialogs spawn in a new process, throwing AIM in the background. Had to ignore the Resume() event in these cases (removed it completely in import, ignored it conditionally in export) so the import/export wizards weren't reset. Looks like things are working on both platforms, so I'm checking in the fix. Will test further.
  • Loading branch information
eb1 committed Feb 1, 2024
1 parent 55e83c4 commit 7d3aee1
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions www/js/views/DocumentViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ define(function (require) {
caseTarget = [],
deferreds = [],
strContents = "",
// EDB 1 Feb 2024: static for the export wizard, to ignore the app process pause/resume events: on Android, the
// Open and Save plugins pause the app process, so when we get back the "operation succeeded / failed" status messages
// get knocked out and replaced by the wizard restarting (ugh). I removed the resume handler from the import side completely.
bOperationDone = false,
END_FT_BIT = "0000000010000000000000", // pos 13 (4096 in decimal), per Adapt It Desktop
bOverride = false, // if we are merging, do we want to automatically choose this data over what's
// in the database?
Expand Down Expand Up @@ -3999,6 +4003,7 @@ define(function (require) {
// Callback for when the file is imported / saved successfully
var exportSuccess = function () {
console.log("exportSuccess()");
bOperationDone = true;
// update status
if (isClipboard === true) {
// just tell the user it succeeded
Expand All @@ -4013,12 +4018,14 @@ define(function (require) {
// display the OK button
$("#loading").hide();
$("#waiting").hide();
$("#btnCancel").hide();
$("#btnOK").removeClass("hide");
$("#btnOK").removeAttr("disabled");
};
// Callback for when the file failed to import
var exportFail = function (e) {
console.log("exportFail(): " + e.message);
bOperationDone = true;
isClipboard = false; // reset the clipboard flag
// update status
$("#status").html(i18n.t("view.dscExportFailed", {document: filename, reason: e.message}));
Expand Down Expand Up @@ -6028,7 +6035,6 @@ define(function (require) {
isLoadingFromURL: false,

initialize: function () {
document.addEventListener("resume", this.onResume, false);
this.bookList = new bookModel.BookCollection();
},

Expand All @@ -6042,12 +6048,6 @@ define(function (require) {
"click #btnCancel": "onCancel",
"click #OK": "onOK"
},
// Resume handler -- user placed the app in the background, then resumed.
// Assume the file list could have changed, and reload this page
onResume: function () {
// refresh the view
Backbone.history.loadUrl(Backbone.history.fragment);
},
// Handler for when another process sends us a file to import. The logic is in
// window.handleOpenURL (main.js) and Application::importFileFromURL() (Application.js).
importFromURL: function (file) {
Expand Down Expand Up @@ -6378,10 +6378,12 @@ define(function (require) {
destination: DestinationEnum.FILE,
content: contentEnum.ADAPTATION,
template: Handlebars.compile(tplExportDoc),

initialize: function () {
document.addEventListener("resume", this.onResume, false);
this.bookList = new bookModel.BookCollection();
},

////
// Event Handlers
////
Expand All @@ -6398,10 +6400,11 @@ define(function (require) {
"click #Cancel": "onCancel"
},
// Resume handler -- user placed the app in the background, then resumed.
// Assume the file list could have changed, and reload this page
onResume: function () {
// refresh the view
Backbone.history.loadUrl(Backbone.history.fragment);
// reload the Export wizard, UNLESS we got bumped out by the doc Save process
if (bOperationDone === false) {
Backbone.history.loadUrl(Backbone.history.fragment);
}
},
// User wants to export the adaptation / target text. For Adapt It (.xml) format, this includes the gloss and FT data.
onExportAdaptation: function () {
Expand Down Expand Up @@ -6491,6 +6494,7 @@ define(function (require) {
if ($("#buildAIDocXML").length === 0) {
// if this is the export complete page,
// go back to the previous page
bOperationDone = false;
window.history.go(-1);
} else {
var format = FileTypeEnum.TXT;
Expand Down Expand Up @@ -6573,6 +6577,7 @@ define(function (require) {
// User clicked the Cancel button DURING EXPORT. This is probably due to a hung export process
onBtnCancel: function () {
// TODO: roll back any changes?
bOperationDone = false;
// go back to the previous page
if (window.history.length > 1) {
// there actually is a history -- go back
Expand All @@ -6584,6 +6589,7 @@ define(function (require) {
},
// User clicked the Cancel button. Here we don't do anything -- just return
onCancel: function () {
bOperationDone = false;
// go back to the previous page
if (window.history.length > 1) {
// there actually is a history -- go back
Expand All @@ -6595,6 +6601,7 @@ define(function (require) {
},
// User clicked the OK button AFTER EXPORT success/fail. Here we don't do anything -- just return
onBtnOK: function () {
bOperationDone = false;
// go back to the previous page
if (window.history.length > 1) {
// there actually is a history -- go back
Expand Down Expand Up @@ -6669,6 +6676,7 @@ define(function (require) {
}
},
onShow: function () {
bOperationDone = false; // reset the operation done flag
kblist = window.Application.kbList;
$.when(kblist.fetch({reset: true, data: {projectid: window.Application.currentProject.get("projectid")}})).done(function() {
// first step -- clipboard or file?
Expand Down

0 comments on commit 7d3aee1

Please sign in to comment.