Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add Lemmy Donation Dialog#1813

Merged
dessalines merged 8 commits into
LemmyNet:mainfrom
iByteABit256:add_donation_dialogue
May 7, 2025
Merged

Add Lemmy Donation Dialog#1813
dessalines merged 8 commits into
LemmyNet:mainfrom
iByteABit256:add_donation_dialogue

Conversation

@iByteABit256

Copy link
Copy Markdown
Contributor

Fixes #1794

Added a Donation Dialog in MainActivity which shows the donation message in case the user:

  • is logged in
  • uses a server running a version which supports the donation dialog feature
  • hasn't been shown a donation dialog for at least a year

The dialog has a Donate button, a No Thanks button and the ability to dismiss it by clicking outside.
If the user clicks Donate they get navigated to the donation page, and in all of the cases a POST request is then sent to the donation_dialog_shown endpoint to update that the user has seen it, then the dialog closes.

Also bumped the lemmy-api version to 0.4.1.

Comment thread app/src/main/java/com/jerboa/model/LocalUserViewModel.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/home/donation/DonationDialog.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/home/donation/DonationDialog.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/home/donation/DonationDialog.kt Outdated
Comment thread app/src/main/java/com/jerboa/model/LocalUserViewModel.kt Outdated

@MV-GH MV-GH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How does this work with changelog dialog? Does it stack on top of each other?

Looks otherwise good to me.

Comment thread app/src/main/res/values/strings.xml Outdated
) {
if (API.getInstanceOrNull()?.FF?.markDonationDialogShown() == true) {
scope.launch {
val result = API.getInstance().markDonationDialogShown()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Chain it directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can't chain it because I'm using the feature flags on l146, I refactored it with an api variable instead

@MV-GH MV-GH changed the title Add Donation Dialog Add Lemmy Donation Dialog May 2, 2025
@iByteABit256

Copy link
Copy Markdown
Contributor Author

The changelog would conflict a bit with the donation dialog if both should be shown, I made a combined app startup dialogs component that manages the order they should be shown

@iByteABit256 iByteABit256 requested a review from MV-GH May 3, 2025 12:58
Comment thread app/src/main/java/com/jerboa/ui/components/home/AppStartupDialogs.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/home/AppStartupDialogs.kt Outdated
Comment thread app/src/main/java/com/jerboa/ui/components/home/AppStartupDialogs.kt Outdated
}

// Determine which dialog to show
LaunchedEffect(changelogNeedsToShow, donationNeedsToShow) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Whats the reason for this launched affect here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It works like you mentioned in the later comment, and I also made it to check activeDialog for null. This is because changelog changing to shouldShow = true for example would override the donation dialog currently showing. Now it waits until the current dialog is closed and then it changes the activeDialog.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But I don't see why its needed?

Couldn't you get the exact same result by just removing the effect?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can imagine a scenario where the dialog has closed and activeDialog is null again, but the shouldShow logic for one of the dialogs hasn't received updated data yet for the condition to change, making the dialog open up again a second time

@dessalines dessalines left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

The only potential change I can think of, is to prepend the donation dialog text to the changelog when both need to be shown, but that's up to you.

Comment thread app/src/main/java/com/jerboa/ui/components/home/AppStartupDialogs.kt Outdated
@dessalines dessalines requested a review from MV-GH May 6, 2025 14:17

@MV-GH MV-GH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's okay for me, just haven't tested it

@dessalines dessalines left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just tested this out, and it works well. Thx!

@dessalines dessalines merged commit 5deebbb into LemmyNet:main May 7, 2025
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.

Add Donation Dialog

3 participants