feat: add donation dialog, close #524 (#597)

* feat: add donation dialog, close #524

* fix: command palette broken
This commit is contained in:
Xylight authored and GitHub committed 2025-06-25 23:50:08 +00:00
1 parent 58d5be7027
commit f1f3955a7b
12 files changed
+134 -60

No files matched your search

+37 -1
View File
@@ -18,6 +18,7 @@ import { writable } from 'svelte/store'
import { t } from './i18n/translations'
import { site } from './lemmy.svelte'
import { errorMessage } from './lemmy/error'
import { publishedToDate } from './components/util/date'
const getDefaultProfile = (): Profile => ({
id: -1,
@@ -173,6 +174,7 @@ $effect.root(() => {
})
})
// cookie migration code
if (
env.PUBLIC_MIGRATE_COOKIE &&
profileData.profiles.length == 0 &&
@@ -365,4 +367,38 @@ async function checkInbox() {
})
}
setInterval(checkInbox, 4 * 60 * 1000)
async function init() {
setInterval(checkInbox, 4 * 60 * 1000)
// hacky way to check donation status
setTimeout(() => {
if (
profile.data.user?.local_user_view.local_user.last_donation_notification
) {
const donationDate = publishedToDate(
profile.data.user?.local_user_view.local_user
.last_donation_notification,
)
if (Date.now() - donationDate.getTime() > 365 * 24 * 60 * 60 * 1000) {
toast({
content: t.get('toast.lemmyDonate'),
duration: 3600 * 1000,
long: true,
})
// lemmy js client donation dialog is broken
fetch(
`${instanceToURL(profile.data.instance)}/api/v3/user/donation_dialog_shown`,
{
method: 'POST',
headers: {
authorization: `Bearer ${profile.data.jwt}`,
},
},
)
}
}
}, 3 * 1000)
}
init()