Merge pull request #2483 from beekeeper-studio/feature/free-reminder

feat: have the "buy beekeeper" update show up every 3 hours when using community
This commit is contained in:
Matthew Rathbone
2025-03-16 12:13:44 -05:00
committed by GitHub
2 changed files with 44 additions and 15 deletions

View File

@@ -2,16 +2,18 @@
<div v-if="false" />
</template>
<script lang="ts">
import { SmartLocalStorage } from '@/common/LocalStorage'
import Vue from 'vue'
import Noty from 'noty'
import { mapGetters } from 'vuex'
export default Vue.extend({
data: () => {
return {
upsellNotification: new Noty({
notificationInterval: null,
timeoutID: null,
upsellNotificationOptions: {
text: "👋 Beekeeper Studio is run by a small team. Buy the full version of Beekeeper Studio to support development and get more features. Thank you ♥",
timeout: false,
timeout: 1000 * 60 * 5,
queue: "upsell",
killer: 'upsell',
layout: 'bottomRight',
@@ -20,21 +22,45 @@ export default Vue.extend({
Noty.button('Close', 'btn btn-flat', () => Noty.closeAll('upsell')),
Noty.button('Get Started', 'btn btn-primary', () => window.main.openExternally('https://docs.beekeeperstudio.io/docs/upgrading-from-the-community-edition'))
]
})
}
}
},
computed: {
...mapGetters({
'isCommunity': 'isCommunity',
})
},
watch: {
isCommunity() {
this.initNotifyInterval()
}
},
methods: {
initNotifyInterval() {
const intervalTime = 1000 * 60 * 60 * 3
if (this.notificationInterval) {
clearInterval(this.notificationInterval)
this.notificationInterval = null
}
if (this.timeoutID) {
clearTimeout(this.timeoutID)
this.timeoutID = null
}
if (!this.isCommunity) {
return
}
this.notificationInterval = setInterval(() => {
new Noty(this.upsellNotificationOptions).show()
}, intervalTime)
this.timeoutID = setTimeout(() => {
new Noty(this.upsellNotificationOptions).show()
}, 1000 * 60 * 5)
}
},
mounted() {
if (this.$store.getters.isCommunity) {
const today = new Date()
const upgradeSuggested = SmartLocalStorage.getDate('ultimate-upsell')
const lastWeek = new Date(today.getTime() - (28 * 24 * 60 * 60 * 1000))
if (!upgradeSuggested || upgradeSuggested < lastWeek) {
setTimeout(() => {
this.upsellNotification.show()
SmartLocalStorage.setDate('ultimate-upsell', today)
}, (1000 * 60 * 5)) // 5 minutes
}
}
this.initNotifyInterval()
}
})
</script>

View File

@@ -416,6 +416,9 @@ const store = new Vuex.Store<State>({
const days = context.rootGetters['licenses/licenseDaysLeft']
title += ` - Free Trial (${window.main.pluralize('day', days, true)} left)`
}
if (context.getters.isCommunity) {
title += ' - Free Version'
}
context.commit('updateWindowTitle', title)
window.main.setWindowTitle(title);
},