Statuses
@@ -58,14 +60,25 @@
export default {
props: [ 'user' ],
computed: {
- style () {
+ headingStyle () {
+ let rgb = this.$store.state.config.colors['base00'].match(/\d+/g)
return {
- color: `#${this.user.profile_link_color}`,
- 'background-image': `url(${this.user.cover_photo})`
+ backgroundColor: 'rgb(' + Math.floor(rgb[0] * 0.53) + ', ' +
+ Math.floor(rgb[1] * 0.56) + ', ' +
+ Math.floor(rgb[2] * 0.59) + ')',
+ backgroundImage: `url(${this.user.cover_photo})`
+ }
+ },
+ bodyStyle () {
+ return {
+ background: 'linear-gradient(to bottom, rgba(0, 0, 0, 0), ' + this.$store.state.config.colors['base00'] + ' 80%)'
}
},
isOtherUser () {
return this.user !== this.$store.state.users.currentUser
+ },
+ loggedIn () {
+ return this.$store.state.users.currentUser
}
},
methods: {
@@ -87,3 +100,118 @@
}
}
+
+
diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue
index b0d6db8588..11a61bfc95 100644
--- a/src/components/user_profile/user_profile.vue
+++ b/src/components/user_profile/user_profile.vue
@@ -7,45 +7,10 @@
diff --git a/src/lib/persisted_state.js b/src/lib/persisted_state.js
index de1e5383d1..6a17ca993e 100644
--- a/src/lib/persisted_state.js
+++ b/src/lib/persisted_state.js
@@ -1,7 +1,7 @@
import merge from 'lodash.merge'
import objectPath from 'object-path'
import { throttle } from 'lodash'
-import { inflate, deflate } from 'pako'
+import lzstring from 'lz-string'
const defaultReducer = (state, paths) => (
paths.length === 0 ? state : paths.reduce((substate, path) => {
@@ -36,22 +36,22 @@ const defaultStorage = (() => {
})()
const defaultSetState = (key, state, storage) => {
- return storage.setItem(key, deflate(JSON.stringify(state), { to: 'string' }))
+ return storage.setItem(key, lzstring.compressToUTF16(JSON.stringify(state)))
}
export default function createPersistedState ({
- key = 'vuex',
+ key = 'vuex-lz',
paths = [],
getState = (key, storage) => {
let value = storage.getItem(key)
try {
- value = inflate(value, { to: 'string' })
+ value = lzstring.decompressFromUTF16(value) // inflate(value, { to: 'string' })
} catch (e) {
console.log("Couldn't inflate value... Maybe upgrading")
}
return value && value !== 'undefined' ? JSON.parse(value) : undefined
},
- setState = throttle(defaultSetState, 5000),
+ setState = throttle(defaultSetState, 60000),
reducer = defaultReducer,
storage = defaultStorage,
subscriber = store => handler => store.subscribe(handler)
diff --git a/src/main.js b/src/main.js
index 6fa95e121b..0783749e18 100644
--- a/src/main.js
+++ b/src/main.js
@@ -29,7 +29,12 @@ Vue.use(VueTimeago, {
})
const persistedStateOptions = {
- paths: ['users.users', 'statuses.notifications']
+ paths: [
+ 'config.hideAttachments',
+ 'config.hideNsfw',
+ 'statuses.notifications',
+ 'users.users'
+ ]
}
const store = new Vuex.Store({
diff --git a/src/modules/config.js b/src/modules/config.js
index a1276519db..896a6978ef 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -2,7 +2,10 @@ import { set } from 'vue'
import StyleSetter from '../services/style_setter/style_setter.js'
const defaultState = {
- name: 'Pleroma FE'
+ name: 'Pleroma FE',
+ colors: {},
+ hideAttachments: false,
+ hideNsfw: true
}
const config = {
@@ -24,7 +27,7 @@ const config = {
break
case 'theme':
const fullPath = `/static/css/${value}`
- StyleSetter.setStyle(fullPath)
+ StyleSetter.setStyle(fullPath, commit)
}
}
}
diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js
index 0a5be77d04..7129852d3b 100644
--- a/src/services/style_setter/style_setter.js
+++ b/src/services/style_setter/style_setter.js
@@ -1,4 +1,6 @@
-const setStyle = (href) => {
+import { times } from 'lodash'
+
+const setStyle = (href, commit) => {
/***
What's going on here?
I want to make it easy for admins to style this application. To have
@@ -23,18 +25,26 @@ const setStyle = (href) => {
const setDynamic = () => {
const baseEl = document.createElement('div')
body.appendChild(baseEl)
- baseEl.setAttribute('class', 'base05')
- const base05Color = window.getComputedStyle(baseEl).getPropertyValue('color')
- baseEl.setAttribute('class', 'base08')
- const base08Color = window.getComputedStyle(baseEl).getPropertyValue('color')
+
+ let colors = {}
+ times(16, (n) => {
+ const name = `base0${n.toString(16).toUpperCase()}`
+ baseEl.setAttribute('class', name)
+ const color = window.getComputedStyle(baseEl).getPropertyValue('color')
+ colors[name] = color
+ })
+
+ commit('setOption', { name: 'colors', value: colors })
+
+ body.removeChild(baseEl)
+
const styleEl = document.createElement('style')
head.appendChild(styleEl)
const styleSheet = styleEl.sheet
- body.removeChild(baseEl)
- styleSheet.insertRule(`a { color: ${base08Color}`, 'index-max')
- styleSheet.insertRule(`body { color: ${base05Color}`, 'index-max')
- styleSheet.insertRule(`.base05-border { border-color: ${base05Color}`, 'index-max')
+ styleSheet.insertRule(`a { color: ${colors['base08']}`, 'index-max')
+ styleSheet.insertRule(`body { color: ${colors['base05']}`, 'index-max')
+ styleSheet.insertRule(`.base05-border { border-color: ${colors['base05']}`, 'index-max')
body.style.display = 'initial'
}
cssEl.addEventListener('load', setDynamic)
diff --git a/yarn.lock b/yarn.lock
index 4d5a5f6174..92f734bc12 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3549,6 +3549,10 @@ lru-cache@~2.6.5:
version "2.6.5"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.6.5.tgz#e56d6354148ede8d7707b58d143220fd08df0fd5"
+lz-string@^1.4.4:
+ version "1.4.4"
+ resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26"
+
macaddress@^0.2.8:
version "0.2.8"
resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12"
@@ -4052,10 +4056,6 @@ pac-resolver@~1.2.1:
regenerator "~0.8.13"
thunkify "~2.1.1"
-pako@^1.0.4:
- version "1.0.4"
- resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.4.tgz#412cc97c3b7ff06dc6c2557fd4f03d06f5e708d4"
-
pako@~0.2.0:
version "0.2.9"
resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75"
@@ -5629,12 +5629,6 @@ vue-router@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-2.2.1.tgz#b027f9fac2cf13462725e843d6dc631b6aa077f6"
-vue-style-loader@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-1.0.0.tgz#abeb7bd0f46313083741244d3079d4f14449e049"
- dependencies:
- loader-utils "^0.2.7"
-
vue-style-loader@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/vue-style-loader/-/vue-style-loader-2.0.0.tgz#1a3bb55239ac541ee3af0301d66f16fc86786543"