Skip to content

Conversation

@kdeakinstructure
Copy link
Contributor

@kdeakinstructure kdeakinstructure commented Dec 16, 2025

Show toast message when click on 'Add Bookmark' button on the Assignment List Page in Offline mode (just like we do on other pages).

refs: MBL-19634
affects: Student
release note: Show toast message in offline mode 'Add Bookmark' button click on Assignment List Page.

  • Tested in light mode

…ent List page in Offline mode.

refs: MBL-19634
affects: Student
release note: Show toast message in offline mode 'Add Bookmark' button click on Assignment List Page.
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR adds an offline check before allowing bookmark creation in the student assignment list, which is a good improvement for user experience. The implementation prevents the dialog from showing when there's no network connection and displays an appropriate message to the user.

Positive aspects:

  • Prevents unnecessary dialog display when offline
  • Uses existing APIHelper.hasNetworkConnection() utility
  • Provides user feedback with an appropriate offline message
  • Simple and focused change

Areas for improvement:

  • Architecture concern - Toast is used directly in the behavior class (line 98), which couples UI presentation logic with business logic. Consider refactoring to return state/results that the Fragment can handle for better testability and separation of concerns.

  • Consistency check needed - Verify if other network-dependent operations in the assignments list feature have similar offline checks. This PR only adds it to bookmark creation.

  • Race condition consideration - The network check happens before showing the dialog, but the network could drop between the check and the actual API call. Ensure BookmarkCreationDialog handles offline states gracefully during execution.

Testing recommendations:

  • Test the bookmark creation flow in offline mode
  • Test network dropping between the check and dialog interaction
  • Verify the Toast message displays correctly and is accessible

Overall, this is a straightforward improvement that enhances the offline experience. The inline comments provide suggestions for architectural improvements that could be addressed now or in future refactoring.

val dialog = BookmarkCreationDialog.newInstance(activity, fragment, null)
dialog?.show(activity.supportFragmentManager, BookmarkCreationDialog::class.java.simpleName)
} else {
Toast.makeText(activity, activity.getString(com.instructure.pandautils.R.string.notAvailableOffline), Toast.LENGTH_SHORT).show()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Toast directly in behavior/business logic classes couples the UI layer with the business logic. Consider:

  1. Moving this offline check to a higher level (e.g., in the Fragment/ViewModel)
  2. Or, have the behavior return a result/state that the Fragment can handle (showing Toast or Snackbar)

This would make the code more testable and follow separation of concerns principles.

AssignmentListMenuOverFlowItem(activity.getString(R.string.addBookmark)) {
val dialog = BookmarkCreationDialog.newInstance(activity, fragment, null)
dialog?.show(activity.supportFragmentManager, BookmarkCreationDialog::class.java.simpleName)
if (APIHelper.hasNetworkConnection()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The APIHelper.hasNetworkConnection() check is good, but consider:

  1. This check is only added to the bookmark creation menu item. Are there other actions in this or related classes that should also have offline checks?
  2. The BookmarkCreationDialog itself might attempt network operations - does it handle offline states gracefully if the network drops between this check and the actual API call?

For consistency, it may be worth auditing other network-dependent operations in the assignments list feature.

@github-actions
Copy link

github-actions bot commented Dec 16, 2025

🧪 Unit Test Results

✅ 📱 Student App

  • Tests: 1241 total, 0 failed, 0 skipped
  • Duration: 0.000s
  • Success Rate: 100%

✅ 🌅 Horizon

  • Tests: 449 total, 0 failed, 0 skipped
  • Duration: 33.364s
  • Success Rate: 100%

✅ 📦 Submodules

  • Tests: 2472 total, 0 failed, 0 skipped
  • Duration: 42.872s
  • Success Rate: 100%

📊 Summary

  • Total Tests: 4162
  • Failed: 0
  • Skipped: 0
  • Status: ✅ All tests passed!

Last updated: Wed, 17 Dec 2025 17:01:55 GMT

@github-actions
Copy link

github-actions bot commented Dec 17, 2025

Student Install Page

@github-actions
Copy link

github-actions bot commented Dec 17, 2025

📊 Code Coverage Report

⚠️ Student

  • PR Coverage: 42.91%
  • Master Coverage: 42.91%
  • Delta: -0.01%

✅ Teacher

  • PR Coverage: 25.48%
  • Master Coverage: 25.48%
  • Delta: +0.00%

✅ Pandautils

  • PR Coverage: 22.49%
  • Master Coverage: 22.49%
  • Delta: +0.00%

📈 Overall Average

  • PR Coverage: 30.29%
  • Master Coverage: 30.30%
  • Delta: -0.00%

val dialog = BookmarkCreationDialog.newInstance(activity, fragment, null)
dialog?.show(activity.supportFragmentManager, BookmarkCreationDialog::class.java.simpleName)
} else {
Toast.makeText(activity, activity.getString(com.instructure.pandautils.R.string.notAvailableOffline), Toast.LENGTH_SHORT).show()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be removed com.instructure.pandautils. and imported

also at other screens we use the No internet connection dialog, and we have an extension for this:
com.instructure.pandautils.utils.ActivityExtensionsKt#withRequireNetwork

What do you think? I think toast is better UX, but it is not consistent with the other screens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the package name as we are using the student R (just like in other screens).

However, I would stay with the toast since for 'Add Bookmark' function we are using this approach on other screens as well. You can see it in the corresponding video in the bug ticket.

Copy link
Contributor

@kristofnemere kristofnemere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA+1

@kdeakinstructure kdeakinstructure merged commit 624fe12 into master Dec 18, 2025
27 checks passed
@kdeakinstructure kdeakinstructure deleted the MBL-19634-display-toast-while-click-add-bookmark-on-assignment-list branch December 18, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants