From 56fec664a9bb5c1539423e396c127c4a45e8f4e9 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 19 Nov 2018 20:22:46 +0300 Subject: cleanup and optimization --- src/modules/config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules/config.js') diff --git a/src/modules/config.js b/src/modules/config.js index 375d0167..96f2fd5e 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -1,5 +1,5 @@ import { set, delete as del } from 'vue' -import StyleSetter from '../services/style_setter/style_setter.js' +import { setPreset, setColors } from '../services/style_setter/style_setter.js' const browserLocale = (window.navigator.language || 'en').split('-')[0] @@ -51,10 +51,10 @@ const config = { commit('setOption', {name, value}) switch (name) { case 'theme': - StyleSetter.setPreset(value, commit) + setPreset(value, commit) break case 'customTheme': - StyleSetter.setColors(value, commit) + setColors(value, commit) } } } -- cgit v1.2.3-70-g09d2 From bbae2e10f3214d4a38b31234fa01f92a52417b0b Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Fri, 7 Dec 2018 15:15:31 +0700 Subject: Add configuration to enable/disable web push notifications --- src/modules/config.js | 1 + src/services/push/push.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/modules/config.js') diff --git a/src/modules/config.js b/src/modules/config.js index f23cacb7..1ad9df07 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -23,6 +23,7 @@ const defaultState = { likes: true, repeats: true }, + webPushNotifications: true, muteWords: [], highlight: {}, interfaceLanguage: browserLocale, diff --git a/src/services/push/push.js b/src/services/push/push.js index 7d99648a..28954948 100644 --- a/src/services/push/push.js +++ b/src/services/push/push.js @@ -1,4 +1,3 @@ - function urlBase64ToUint8Array (base64String) { const padding = '='.repeat((4 - base64String.length % 4) % 4) const base64 = (base64String + padding) @@ -46,6 +45,10 @@ function askPermission () { } function subscribe (registration, store) { + if (!store.rootState.config.webPushNotifications) { + return Promise.reject(new Error('Web Push is disabled in config')) + } + if (!store.rootState.instance.vapidPublicKey) { return Promise.reject(new Error('VAPID publick key is not found')) } -- cgit v1.2.3-70-g09d2 From 51dccb788798364bbb662d378f2aa2647f1845cf Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 11 Dec 2018 02:46:17 +0300 Subject: separated preview and exported from style_switcher --- src/components/export_import/export_import.vue | 75 ++++++++++++++++++ src/components/style_switcher/preview.vue | 78 +++++++++++++++++++ src/components/style_switcher/style_switcher.js | 97 ++++++++---------------- src/components/style_switcher/style_switcher.vue | 93 +++-------------------- src/modules/config.js | 4 +- 5 files changed, 200 insertions(+), 147 deletions(-) create mode 100644 src/components/export_import/export_import.vue create mode 100644 src/components/style_switcher/preview.vue (limited to 'src/modules/config.js') diff --git a/src/components/export_import/export_import.vue b/src/components/export_import/export_import.vue new file mode 100644 index 00000000..9914d54a --- /dev/null +++ b/src/components/export_import/export_import.vue @@ -0,0 +1,75 @@ + + + diff --git a/src/components/style_switcher/preview.vue b/src/components/style_switcher/preview.vue new file mode 100644 index 00000000..09a136e9 --- /dev/null +++ b/src/components/style_switcher/preview.vue @@ -0,0 +1,78 @@ + diff --git a/src/components/style_switcher/style_switcher.js b/src/components/style_switcher/style_switcher.js index adcbee25..50cd1e6f 100644 --- a/src/components/style_switcher/style_switcher.js +++ b/src/components/style_switcher/style_switcher.js @@ -8,6 +8,8 @@ import ShadowControl from '../shadow_control/shadow_control.vue' import FontControl from '../font_control/font_control.vue' import ContrastRatio from '../contrast_ratio/contrast_ratio.vue' import TabSwitcher from '../tab_switcher/tab_switcher.jsx' +import Preview from './preview.vue' +import ExportImport from '../export_import/export_import.vue' // List of color values used in v1 const v1OnlyNames = [ @@ -26,7 +28,6 @@ export default { return { availableStyles: [], selected: this.$store.state.config.theme, - invalidThemeImported: false, previewShadows: {}, previewColors: {}, @@ -293,20 +294,11 @@ export default { }, themeValid () { return !this.shadowsInvalid && !this.colorsInvalid && !this.radiiInvalid - } - }, - components: { - ColorInput, - OpacityInput, - RangeInput, - ContrastRatio, - ShadowControl, - FontControl, - TabSwitcher - }, - methods: { - exportCurrentTheme () { + }, + exportedTheme () { const saveEverything = !this.keepFonts && !this.keepShadows && !this.keepColors && !this.keepOpacity && !this.keepRoundness + + // TODO change into delete-less version. const theme = { shadows: this.shadowsLocal, fonts: this.fontsLocal, @@ -331,57 +323,24 @@ export default { delete theme.radii } - const stringified = JSON.stringify({ + return { // To separate from other random JSON files and possible future theme formats _pleroma_theme_version: 2, theme - }, null, 2) // Pretty-print and indent with 2 spaces - - // Create an invisible link with a data url and simulate a click - const e = document.createElement('a') - e.setAttribute('download', 'pleroma_theme.json') - e.setAttribute('href', 'data:application/json;base64,' + window.btoa(stringified)) - e.style.display = 'none' - - document.body.appendChild(e) - e.click() - document.body.removeChild(e) - }, - - importTheme () { - this.invalidThemeImported = false - const filePicker = document.createElement('input') - filePicker.setAttribute('type', 'file') - filePicker.setAttribute('accept', '.json') - - filePicker.addEventListener('change', event => { - if (event.target.files[0]) { - // eslint-disable-next-line no-undef - const reader = new FileReader() - reader.onload = ({target}) => { - try { - const parsed = JSON.parse(target.result) - if (parsed._pleroma_theme_version === 1) { - this.normalizeLocalState(parsed, 1) - } else if (parsed._pleroma_theme_version === 2) { - this.normalizeLocalState(parsed.theme, 2) - } else { - // A theme from the future, spooky - this.invalidThemeImported = true - } - } catch (e) { - // This will happen both if there is a JSON syntax error or the theme is missing components - this.invalidThemeImported = true - } - } - reader.readAsText(event.target.files[0]) - } - }) - - document.body.appendChild(filePicker) - filePicker.click() - document.body.removeChild(filePicker) - }, - + } + } + }, + components: { + ColorInput, + OpacityInput, + RangeInput, + ContrastRatio, + ShadowControl, + FontControl, + TabSwitcher, + Preview, + ExportImport + }, + methods: { setCustomTheme () { this.$store.dispatch('setOption', { name: 'customTheme', @@ -394,7 +353,17 @@ export default { } }) }, - + onImport (parsed) { + if (parsed._pleroma_theme_version === 1) { + this.normalizeLocalState(parsed, 1) + } else if (parsed._pleroma_theme_version === 2) { + this.normalizeLocalState(parsed.theme, 2) + } + }, + importValidator (parsed) { + const version = parsed._pleroma_theme_version + return version >= 1 || version <= 2 + }, clearAll () { const state = this.$store.state.config.customTheme const version = state.colors ? 2 : 'l1' diff --git a/src/components/style_switcher/style_switcher.vue b/src/components/style_switcher/style_switcher.vue index 9de60f7b..730bfef0 100644 --- a/src/components/style_switcher/style_switcher.vue +++ b/src/components/style_switcher/style_switcher.vue @@ -18,11 +18,14 @@ -
- - -

{{ $t('settings.invalid_theme_imported') }}

-
+
@@ -58,82 +61,7 @@
-
-
-
- {{$t('settings.style.preview.header')}} - - 99 - -
- - {{$t('settings.style.preview.header_faint')}} - - - {{$t('settings.style.preview.error')}} - - -
-
-
-
- ( ͡° ͜ʖ ͡°) -
-
-

- {{$t('settings.style.preview.content')}} -

- - - - {{$t('settings.style.preview.mono')}} - - - {{$t('settings.style.preview.link')}} - - - -
- - - - -
-
-
- -
-
- :^) -
- -
-
- - - {{$t('settings.style.preview.error')}} - - - -
- - - - - -
-
-
+
@@ -235,6 +163,7 @@ +

{{$t('settings.radii_help')}}

@@ -249,6 +178,7 @@
+
@@ -294,6 +224,7 @@

{{$t('settings.style.shadows.filter_hint.spread_zero')}}

+

{{$t('settings.style.fonts.help')}}

diff --git a/src/modules/config.js b/src/modules/config.js index fb9b3ca6..45ac8f65 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -1,5 +1,5 @@ import { set, delete as del } from 'vue' -import { setPreset, setColors } from '../services/style_setter/style_setter.js' +import { setPreset, applyTheme } from '../services/style_setter/style_setter.js' const browserLocale = (window.navigator.language || 'en').split('-')[0] @@ -57,7 +57,7 @@ const config = { setPreset(value, commit) break case 'customTheme': - setColors(value, commit) + applyTheme(value, commit) } } } -- cgit v1.2.3-70-g09d2 From 7b4e08dd93520e3dc1113d76e097b998d12b0f3c Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 03:33:53 +0530 Subject: added config for preload and made attachment responsive to it --- src/components/attachment/attachment.js | 3 ++- src/components/attachment/attachment.vue | 3 +-- src/components/settings/settings.js | 4 ++++ src/components/settings/settings.vue | 4 ++++ src/i18n/en.json | 1 + src/modules/config.js | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src/modules/config.js') diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 41730720..71ef2ca4 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -13,6 +13,7 @@ const Attachment = { return { nsfwImage, hideNsfwLocal: this.$store.state.config.hideNsfw, + preloadNsfwImage: this.$store.state.config.preloadNsfwImage, loopVideo: this.$store.state.config.loopVideo, showHidden: false, loading: false, @@ -27,7 +28,7 @@ const Attachment = { return fileTypeService.fileType(this.attachment.mimetype) }, hidden () { - return this.nsfw && this.hideNsfwLocal && !this.showHidden + return (this.nsfw && this.hideNsfwLocal && !this.showHidden) }, isEmpty () { return (this.type === 'html' && !this.attachment.oembed) || this.type === 'unknown' diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 6c8a04ed..1b1956e0 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -9,8 +9,7 @@ - - + diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 19bd2e5b..4d8744da 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -14,6 +14,7 @@ const settings = { hideAttachmentsInConvLocal: user.hideAttachmentsInConv, hideNsfwLocal: user.hideNsfw, hideISPLocal: user.hideISP, + preloadNsfwImage: user.preloadNsfwImage, hidePostStatsLocal: typeof user.hidePostStats === 'undefined' ? instance.hidePostStats : user.hidePostStats, @@ -84,6 +85,9 @@ const settings = { hideNsfwLocal (value) { this.$store.dispatch('setOption', { name: 'hideNsfw', value }) }, + preloadNsfwImage(value) { + this.$store.dispatch('setOption', { name: 'preloadNsfwImage', value }) + }, hideISPLocal (value) { this.$store.dispatch('setOption', { name: 'hideISP', value }) }, diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index dec33505..60b70227 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -118,6 +118,10 @@ +
  • + + +
  • diff --git a/src/i18n/en.json b/src/i18n/en.json index 97dfcb77..dc47788c 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -125,6 +125,7 @@ "hide_attachments_in_convo": "Hide attachments in conversations", "hide_attachments_in_tl": "Hide attachments in timeline", "hide_isp": "Hide instance-specific panel", + "preload_sensitive": "Preload Sensitive Images", "hide_post_stats": "Hide post statistics (e.g. the number of favorites)", "hide_user_stats": "Hide user statistics (e.g. the number of followers)", "import_followers_from_a_csv_file": "Import follows from a csv file", diff --git a/src/modules/config.js b/src/modules/config.js index 45ac8f65..7b0b2cf4 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -9,6 +9,7 @@ const defaultState = { hideAttachments: false, hideAttachmentsInConv: false, hideNsfw: true, + preloadNsfwImage: true, loopVideo: true, loopVideoSilentOnly: true, autoLoad: true, -- cgit v1.2.3-70-g09d2 From 139659d42ca0a877843a4fa1606435dd6f6442db Mon Sep 17 00:00:00 2001 From: ValD Date: Wed, 12 Dec 2018 03:42:29 +0530 Subject: renamed config to preload images and add ident to config --- src/components/attachment/attachment.js | 2 +- src/components/attachment/attachment.vue | 2 +- src/components/settings/settings.js | 6 +++--- src/components/settings/settings.vue | 10 ++++++---- src/i18n/en.json | 2 +- src/modules/config.js | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/modules/config.js') diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 71ef2ca4..fd9a2057 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -13,7 +13,7 @@ const Attachment = { return { nsfwImage, hideNsfwLocal: this.$store.state.config.hideNsfw, - preloadNsfwImage: this.$store.state.config.preloadNsfwImage, + preloadImage: this.$store.state.config.preloadImage, loopVideo: this.$store.state.config.loopVideo, showHidden: false, loading: false, diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 1b1956e0..5eaa0d1d 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -9,7 +9,7 @@ - + diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 4d8744da..9a658536 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -14,7 +14,7 @@ const settings = { hideAttachmentsInConvLocal: user.hideAttachmentsInConv, hideNsfwLocal: user.hideNsfw, hideISPLocal: user.hideISP, - preloadNsfwImage: user.preloadNsfwImage, + preloadImage: user.preloadImage, hidePostStatsLocal: typeof user.hidePostStats === 'undefined' ? instance.hidePostStats : user.hidePostStats, @@ -85,8 +85,8 @@ const settings = { hideNsfwLocal (value) { this.$store.dispatch('setOption', { name: 'hideNsfw', value }) }, - preloadNsfwImage(value) { - this.$store.dispatch('setOption', { name: 'preloadNsfwImage', value }) + preloadImage(value) { + this.$store.dispatch('setOption', { name: 'preloadImage', value }) }, hideISPLocal (value) { this.$store.dispatch('setOption', { name: 'hideISP', value }) diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index 60b70227..b98d4c1a 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -118,10 +118,12 @@
  • -
  • - - -
  • +
      +
    • + + +
    • +
  • diff --git a/src/i18n/en.json b/src/i18n/en.json index dc47788c..92429e4b 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -125,7 +125,7 @@ "hide_attachments_in_convo": "Hide attachments in conversations", "hide_attachments_in_tl": "Hide attachments in timeline", "hide_isp": "Hide instance-specific panel", - "preload_sensitive": "Preload Sensitive Images", + "preload_images": "Preload images", "hide_post_stats": "Hide post statistics (e.g. the number of favorites)", "hide_user_stats": "Hide user statistics (e.g. the number of followers)", "import_followers_from_a_csv_file": "Import follows from a csv file", diff --git a/src/modules/config.js b/src/modules/config.js index 7b0b2cf4..72839476 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -9,7 +9,7 @@ const defaultState = { hideAttachments: false, hideAttachmentsInConv: false, hideNsfw: true, - preloadNsfwImage: true, + preloadImage: true, loopVideo: true, loopVideoSilentOnly: true, autoLoad: true, -- cgit v1.2.3-70-g09d2