logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

update_notification.js (2246B)


  1. import Modal from 'src/components/modal/modal.vue'
  2. import { library } from '@fortawesome/fontawesome-svg-core'
  3. import pleromaTan from 'src/assets/pleromatan_apology.png'
  4. import pleromaTanFox from 'src/assets/pleromatan_apology_fox.png'
  5. import pleromaTanMask from 'src/assets/pleromatan_apology_mask.png'
  6. import pleromaTanFoxMask from 'src/assets/pleromatan_apology_fox_mask.png'
  7. import {
  8. faTimes
  9. } from '@fortawesome/free-solid-svg-icons'
  10. library.add(
  11. faTimes
  12. )
  13. export const CURRENT_UPDATE_COUNTER = 1
  14. const UpdateNotification = {
  15. data () {
  16. return {
  17. showingImage: false,
  18. pleromaTanVariant: Math.random() > 0.5 ? pleromaTan : pleromaTanFox,
  19. showingMore: false
  20. }
  21. },
  22. components: {
  23. Modal
  24. },
  25. computed: {
  26. pleromaTanStyles () {
  27. const mask = this.pleromaTanVariant === pleromaTan ? pleromaTanMask : pleromaTanFoxMask
  28. return {
  29. 'shape-outside': 'url(' + mask + ')'
  30. }
  31. },
  32. shouldShow () {
  33. return !this.$store.state.instance.disableUpdateNotification &&
  34. this.$store.state.users.currentUser &&
  35. this.$store.state.serverSideStorage.flagStorage.updateCounter < CURRENT_UPDATE_COUNTER &&
  36. !this.$store.state.serverSideStorage.prefsStorage.simple.dontShowUpdateNotifs
  37. }
  38. },
  39. methods: {
  40. toggleShow () {
  41. this.showingMore = !this.showingMore
  42. },
  43. neverShowAgain () {
  44. this.toggleShow()
  45. this.$store.commit('setFlag', { flag: 'updateCounter', value: CURRENT_UPDATE_COUNTER })
  46. this.$store.commit('setPreference', { path: 'simple.dontShowUpdateNotifs', value: true })
  47. this.$store.dispatch('pushServerSideStorage')
  48. },
  49. dismiss () {
  50. this.$store.commit('setFlag', { flag: 'updateCounter', value: CURRENT_UPDATE_COUNTER })
  51. this.$store.dispatch('pushServerSideStorage')
  52. }
  53. },
  54. mounted () {
  55. this.contentHeightNoImage = this.$refs.animatedText.scrollHeight
  56. // Workaround to get the text height only after mask loaded. A bit hacky.
  57. const newImg = new Image()
  58. newImg.onload = () => {
  59. setTimeout(() => { this.showingImage = true }, 100)
  60. }
  61. newImg.src = this.pleromaTanVariant === pleromaTan ? pleromaTanMask : pleromaTanFoxMask
  62. }
  63. }
  64. export default UpdateNotification