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

67 lines
1.8 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 21:09:42 +02:00
export const CURRENT_UPDATE_COUNTER = 1
2022-08-04 00:56:52 +02:00
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 + ')'
}
},
2022-08-08 11:17:32 +02:00
dynamicStyles () {
return {
'--____extraInfoGroupHeight': this.contentHeight + 'px'
}
},
2022-08-04 00:56:52 +02:00
shouldShow () {
return !this.$store.state.instance.disableUpdateNotification &&
2022-08-08 01:14:09 +02:00
this.$store.state.users.currentUser &&
this.$store.state.serverSideStorage.flagStorage.updateCounter < CURRENT_UPDATE_COUNTER &&
2022-08-04 00:56:52 +02:00
!this.$store.state.serverSideStorage.flagStorage.dontShowUpdateNotifs
}
},
methods: {
toggleShow () {
this.showingMore = !this.showingMore
},
neverShowAgain () {
2022-08-04 01:12:04 +02:00
this.toggleShow()
2022-08-04 21:09:42 +02:00
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 21:09:42 +02:00
this.$store.dispatch('pushServerSideStorage')
2022-08-04 00:56:52 +02:00
}
},
mounted () {
setTimeout(() => {
2022-08-08 11:17:32 +02:00
this.contentHeight = this.$refs.animatedText.scrollHeight
}, 1000)
2022-08-01 23:37:48 +02:00
}
}
2022-08-04 00:56:52 +02:00
export default UpdateNotification