pleroma-fe/src/components/update_notification/update_notification.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-08-01 23:37:48 +02:00
import Modal from 'src/components/modal/modal.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import pleromaTan from 'src/assets/pleromatan_apology.png'
import pleromaTanFox from 'src/assets/pleromatan_apology_fox.png'
import {
faTimes
} from '@fortawesome/free-solid-svg-icons'
library.add(
faTimes
)
2022-08-04 00:56:52 +02:00
const CURRENT_UPDATE_COUNTER = 1
const UpdateNotification = {
2022-08-01 23:37:48 +02:00
data () {
return {
2022-08-04 00:56:52 +02:00
pleromaTanVariant: Math.random() > 0.5 ? pleromaTan : pleromaTanFox,
2022-08-04 01:12:04 +02:00
showingMore: false,
2022-08-04 00:56:52 +02:00
contentHeight: 0
2022-08-01 23:37:48 +02:00
}
},
components: {
Modal
2022-08-04 00:56:52 +02:00
},
computed: {
pleromaTanStyles () {
return {
'shape-outside': 'url(' + this.pleromaTanVariant + ')'
}
},
shouldShow () {
return this.$store.state.serverSideStorage.flagStorage.updateCounter < CURRENT_UPDATE_COUNTER &&
!this.$store.state.serverSideStorage.flagStorage.dontShowUpdateNotifs
}
},
methods: {
toggleShow () {
this.showingMore = !this.showingMore
},
neverShowAgain () {
2022-08-04 01:12:04 +02:00
this.toggleShow()
// this.$store.commit('setFlag', { flag: 'updateCounter', value: CURRENT_UPDATE_COUNTER })
// this.$store.commit('setFlag', { flag: 'dontShowUpdateNotifs', value: 1 })
// this.$store.dispatch('pushServerSideStorage')
2022-08-04 00:56:52 +02:00
},
dismiss () {
this.$store.commit('setFlag', { flag: 'updateCounter', value: CURRENT_UPDATE_COUNTER })
2022-08-04 01:12:04 +02:00
// this.$store.dispatch('pushServerSideStorage')
2022-08-04 00:56:52 +02:00
}
},
mounted () {
setTimeout(() => {
this.contentHeight = this.$refs.content.offsetHeight
}, 10)
2022-08-01 23:37:48 +02:00
}
}
2022-08-04 00:56:52 +02:00
export default UpdateNotification