-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Adjust user messages around the Session Pause feature #2858
Adjust user messages around the Session Pause feature #2858
Conversation
@damagatchi retest this please |
@avazirna It doesn't look like the comments on the original PR are addressed in this PR, let me know if my understanding is wrong. |
7d90d94
to
2b994db
Compare
@shubham1g5 I have entertained a few design alternatives over this, walking the fine line between structural changes and the bare minimum to achieve the goals of this PR. I'm more inclined to leave the structural work for 2.55 where we can have a proper QA and properly assess all the risks. I also don't think that deep changes should be rolled out in a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall approach looks good to me, left some minor comments around code clarity and readability as optional but nice to have feedback.
// note that we have started saving the form | ||
customFormSaveCallback = listener; | ||
interruptAndSaveForm(exit); | ||
interruptAndSaveForm(true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not clear to me from any of the semantics around this method that formSaveCallback
necessarily means that sessionExpiredOrSustended
is true and userTriggered
is false. I suggest that we should either let these values get passed as a paramenter to formSaveCallback
OR rename formSaveCallback
to make it clear that it's only every utilised by auto-save calls which are not a result of explicit user action and that the save is a result of session lifecycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 3ade9b2
} | ||
|
||
private void interruptAndSaveForm(boolean exit) { | ||
private void interruptAndSaveForm(boolean sessionExpiredOrSustended, boolean userTriggered) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename sessionExpiredOrSustended
-> sessionExpired
(assiming session expiry and suspensions are same things here)
private void saveIncompleteFormToDisk(boolean exit) { | ||
saveDataToDisk(exit, false, null, true); | ||
private void saveIncompleteFormToDisk(boolean sessionExpiredOrSuspended, boolean userTriggered) { | ||
boolean shouldExit = sessionExpiredOrSuspended ? FormEntryConstants.EXIT : FormEntryConstants.DO_NOT_EXIT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would prefer if exit
comes directly from caller of the save methods as before instead of us deriving it on the basis of sessionExpiry
. (More scalable, would cause less changes in future if we decide to save due to another reason where we want user to exit as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done 3ade9b2
@@ -20,13 +21,17 @@ public class AndroidFormController extends FormController implements PendingCall | |||
private boolean wasPendingCalloutCancelled; | |||
private FormIndex formIndexToReturnTo = null; | |||
private boolean formCompleteAndSaved = false; | |||
private InterruptedFormState restoredFormSession; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: probably better to call it interrruptedFormState
|
||
private FormAnalyticsHelper formAnalyticsHelper; | ||
|
||
public AndroidFormController(FormEntryController fec, boolean readOnly, FormIndex formIndex) { | ||
public AndroidFormController(FormEntryController fec, boolean readOnly, InterruptedFormState savedFormSession) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inconsistent variable naming. would keep them all as interruptedFormState
if (savedFormSession !=null ){ | ||
formIndexToReturnTo = savedFormSession.getFormIndex(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think we can remove global reference to formIndexToReturnTo
and just derive it from restoredFormSession
when needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formIndexToReturnTo
is nullified after its first use, which makes sense because we are supposed to return to that FormIndex only when loading the form after a session expiration or app kill. Am I missing something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense. no need for a change here.
@avazirna Can you create a ticket describing the pending list of items and make sure it gets prioritised for 2.55. |
This reverts commit 2c3b7bb.
|
||
private FormAnalyticsHelper formAnalyticsHelper; | ||
|
||
public AndroidFormController(FormEntryController fec, boolean readOnly, FormIndex formIndex) { | ||
public AndroidFormController(FormEntryController fec, boolean readOnly, InterruptedFormState savedFormSession) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we mark savedFormSession
and restoredFormSession
as @Nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super(fec, readOnly); | ||
formAnalyticsHelper = new FormAnalyticsHelper(); | ||
formIndexToReturnTo = formIndex; | ||
this.restoredFormSession = savedFormSession; | ||
if (savedFormSession !=null ){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:formatting
5b4b1be
to
3ade9b2
Compare
@@ -59,6 +63,10 @@ public FormIndex getFormIndex() { | |||
return formIndex; | |||
} | |||
|
|||
public boolean getInterruptedDueToSessionExpiration(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename to isInterrupted..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -793,7 +796,7 @@ protected void onExternalAttachmentUpdated() { | |||
} | |||
String formStatus = formRecord.getStatus(); | |||
if (FormRecord.STATUS_INCOMPLETE.equals(formStatus)) { | |||
saveDataToDisk(false, false, null, true); | |||
saveDataToDisk(false, false, null, true, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this save isuserTriggered
as it happens in response to updating an attachment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1063,7 +1066,8 @@ private void loadForm() { | |||
} | |||
|
|||
mFormLoaderTask = new FormLoaderTask<FormEntryActivity>(symetricKey, instanceIsReadOnly, | |||
formEntryRestoreSession.isRecording(), FormEntryInstanceState.mFormRecordPath, this, lastFormIndex) { | |||
formEntryRestoreSession.isRecording(), FormEntryInstanceState.mFormRecordPath, this, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks weird to have a comma just before method call close. No compilation errors here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed that too, bad conflict resolution. Redid it locally, pushing it in a few.
if (sessionStateRecordId != -1) { | ||
SqlStorage<SessionStateDescriptor> sessionStorage = | ||
CommCareApplication.instance().getUserStorage(SessionStateDescriptor.class); | ||
SessionStateDescriptor current = sessionStorage.read(sessionStateRecordId); | ||
InterruptedFormState interruptedFormState = new InterruptedFormState(current.getID(), formIndex, current.getFormRecordId()); | ||
|
||
InterruptedFormState interruptedFormState = new InterruptedFormState(current.getID(), formIndex, current.getFormRecordId(), sessionExpired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not sure on formatting here.
…ving-session-form
15b4fea
to
a776076
Compare
@damagatchi retest this please |
Summary
Copy of #2851
cross-request: cross-request: dimagi/commcare-core#1437