Skip to content
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

PM-11188 show snackbar after import success. PM-13943 add relay for snackbar events across screen contexts. #4152

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

dseverns-livefront
Copy link
Collaborator

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-11188
&
Pt2 of https://bitwarden.atlassian.net/browse/PM-13943

📔 Objective

  • Allow one "screen" to trigger a snackbar on another
  • Show success snackbar on vault and vault settings screen after import login flow

📸 Screenshots

pm11188.mp4

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Contributor

github-actions bot commented Oct 24, 2024

Logo
Checkmarx One – Scan Summary & Detailsdf7013b7-20af-4587-b75b-16b26c91682b

No New Or Fixed Issues Found

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.98%. Comparing base (f3916b4) to head (1895839).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4152      +/-   ##
==========================================
+ Coverage   88.96%   88.98%   +0.01%     
==========================================
  Files         439      441       +2     
  Lines       38198    38250      +52     
  Branches     5346     5352       +6     
==========================================
+ Hits        33984    34036      +52     
  Misses       2347     2347              
  Partials     1867     1867              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

private val mutableSnackbarRelayMap =
mutableMapOf<SnackbarRelay, MutableSharedFlow<BitwardenSnackbarData?>>()

override fun sendSnackbarData(data: BitwardenSnackbarData, relay: SnackbarRelay?) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need to be a nullable SnackbarRelay

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahh, now I see why you did that. Not sure how I feel about it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of the UUIDs, how would you feel about an enum that identified each specific snackbar that requires a relay.

Then you subscribe to all the values you need and you publish to a specific enum value as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I feel like that is the move, may have tried to go a little too agnostic, but no reason why producer and consumer can't know exactly what they are doing when sending/collecting. Great idea!

@dseverns-livefront dseverns-livefront force-pushed the PM-11188-importlogins-success-snackbar branch from 7762cbd to dbd3400 Compare October 25, 2024 20:45
*/
enum class SnackbarRelay {
VaultSettingsRelay,
MyVaultRelay,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Enums should be capitalized:

    VAULT_SETTINGS_RELAY,
    MY_VAULT_RELAY,

viewState = ImportLoginsState.ViewState.InitialContent,
isVaultSyncing = false,
showBottomSheet = false,
snackbarRelay = ImportLoginsArgs(savedStateHandle).snackBarRelay,
Copy link
Collaborator

@david-livefront david-livefront Oct 28, 2024

Choose a reason for hiding this comment

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

Do we need to pass this in as an argument? Could the screen just know to send the correct enum value?

I believe that is how it worked previously, correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it worked like that cause of the "most recent" relay thing, which had the nullable "relay parameter". I can re-add that, I took the suggestion to move to enums to make it so it was always explicit.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But with this new system, the previous screen will be listening for the specific enum type and this screen will send the specific enum type. Wouldn't that be the unique identifier we need to make it work?


private fun getSnackbarDataFlowInternal(
relay: SnackbarRelay,
): MutableSharedFlow<BitwardenSnackbarData?> =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the BitwardenSnackbarData be nullable?

@dseverns-livefront dseverns-livefront force-pushed the PM-11188-importlogins-success-snackbar branch from 98a4bfc to ed969ee Compare October 28, 2024 17:51
@dseverns-livefront dseverns-livefront force-pushed the PM-11188-importlogins-success-snackbar branch from ed969ee to 1895839 Compare October 29, 2024 14:31
@dseverns-livefront dseverns-livefront added this pull request to the merge queue Oct 29, 2024
Merged via the queue into main with commit 8b16135 Oct 29, 2024
9 checks passed
@dseverns-livefront dseverns-livefront deleted the PM-11188-importlogins-success-snackbar branch October 29, 2024 18:49
ifernandezdiaz pushed a commit that referenced this pull request Oct 29, 2024
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.

2 participants