From da55b0d4352d2daf4a8d9f4130d34546e9f01555 Mon Sep 17 00:00:00 2001 From: kPherox Date: Wed, 19 Feb 2020 20:57:58 +0900 Subject: Add fields_text for tooltip --- src/services/entity_normalizer/entity_normalizer.service.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/services') diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index ca79df6f..ca2075a4 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -53,6 +53,12 @@ export const parseUser = (data) => { value: addEmojis(field.value, data.emojis) } }) + output.fields_text = data.fields.map(field => { + return { + name: field.name.replace(/<[^>]*>/g, ''), + value: field.value.replace(/<[^>]*>/g, '') + } + }) // Utilize avatar_static for gif avatars? output.profile_image_url = data.avatar -- cgit v1.2.3-70-g09d2 From 10070394780ac79e9ee1e8548500586a1f78f65b Mon Sep 17 00:00:00 2001 From: Sergey Suprunenko Date: Sun, 10 May 2020 12:54:55 +0200 Subject: Autocomplete domain mutes from list of known instances --- CHANGELOG.md | 1 + .../domain_mute_card/domain_mute_card.js | 11 +++++++++ .../domain_mute_card/domain_mute_card.vue | 15 ++++++++++++ .../settings_modal/tabs/mutes_and_blocks_tab.js | 28 +++++++++++++++------- .../settings_modal/tabs/mutes_and_blocks_tab.vue | 21 +++++++--------- src/i18n/en.json | 2 +- src/modules/instance.js | 17 +++++++++++++ src/services/api/api.service.js | 6 +++++ 8 files changed, 79 insertions(+), 22 deletions(-) (limited to 'src/services') diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e467bc9..11f539da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Add - Added private notifications option for push notifications - 'Copy link' button for statuses (in the ellipsis menu) +- Autocomplete domains from list of known instances ### Changed - Registration page no longer requires email if the server is configured not to require it diff --git a/src/components/domain_mute_card/domain_mute_card.js b/src/components/domain_mute_card/domain_mute_card.js index c8e838ba..f234dcb0 100644 --- a/src/components/domain_mute_card/domain_mute_card.js +++ b/src/components/domain_mute_card/domain_mute_card.js @@ -5,9 +5,20 @@ const DomainMuteCard = { components: { ProgressButton }, + computed: { + user () { + return this.$store.state.users.currentUser + }, + muted () { + return this.user.domainMutes.includes(this.domain) + } + }, methods: { unmuteDomain () { return this.$store.dispatch('unmuteDomain', this.domain) + }, + muteDomain () { + return this.$store.dispatch('muteDomain', this.domain) } } } diff --git a/src/components/domain_mute_card/domain_mute_card.vue b/src/components/domain_mute_card/domain_mute_card.vue index 567d81c5..97aee243 100644 --- a/src/components/domain_mute_card/domain_mute_card.vue +++ b/src/components/domain_mute_card/domain_mute_card.vue @@ -4,6 +4,7 @@ {{ domain }} @@ -12,6 +13,16 @@ {{ $t('domain_mute_card.unmute_progress') }} + + {{ $t('domain_mute_card.mute') }} + + @@ -34,5 +45,9 @@ button { width: 10em; } + + .autosuggest-results & { + padding-left: 1em; + } } diff --git a/src/components/settings_modal/tabs/mutes_and_blocks_tab.js b/src/components/settings_modal/tabs/mutes_and_blocks_tab.js index b0043dbb..40a87b81 100644 --- a/src/components/settings_modal/tabs/mutes_and_blocks_tab.js +++ b/src/components/settings_modal/tabs/mutes_and_blocks_tab.js @@ -32,12 +32,12 @@ const DomainMuteList = withSubscription({ const MutesAndBlocks = { data () { return { - activeTab: 'profile', - newDomainToMute: '' + activeTab: 'profile' } }, created () { this.$store.dispatch('fetchTokens') + this.$store.dispatch('getKnownDomains') }, components: { TabSwitcher, @@ -51,6 +51,14 @@ const MutesAndBlocks = { Autosuggest, Checkbox }, + computed: { + knownDomains () { + return this.$store.state.instance.knownDomains + }, + user () { + return this.$store.state.users.currentUser + } + }, methods: { importFollows (file) { return this.$store.state.api.backendInteractor.importFollows({ file }) @@ -86,13 +94,13 @@ const MutesAndBlocks = { filterUnblockedUsers (userIds) { return reject(userIds, (userId) => { const relationship = this.$store.getters.relationship(this.userId) - return relationship.blocking || userId === this.$store.state.users.currentUser.id + return relationship.blocking || userId === this.user.id }) }, filterUnMutedUsers (userIds) { return reject(userIds, (userId) => { const relationship = this.$store.getters.relationship(this.userId) - return relationship.muting || userId === this.$store.state.users.currentUser.id + return relationship.muting || userId === this.user.id }) }, queryUserIds (query) { @@ -111,12 +119,16 @@ const MutesAndBlocks = { unmuteUsers (ids) { return this.$store.dispatch('unmuteUsers', ids) }, + filterUnMutedDomains (urls) { + return urls.filter(url => !this.user.domainMutes.includes(url)) + }, + queryKnownDomains (query) { + return new Promise((resolve, reject) => { + resolve(this.knownDomains.filter(url => url.toLowerCase().includes(query))) + }) + }, unmuteDomains (domains) { return this.$store.dispatch('unmuteDomains', domains) - }, - muteDomain () { - return this.$store.dispatch('muteDomain', this.newDomainToMute) - .then(() => { this.newDomainToMute = '' }) } } } diff --git a/src/components/settings_modal/tabs/mutes_and_blocks_tab.vue b/src/components/settings_modal/tabs/mutes_and_blocks_tab.vue index 6884b7be..5a1cf2c0 100644 --- a/src/components/settings_modal/tabs/mutes_and_blocks_tab.vue +++ b/src/components/settings_modal/tabs/mutes_and_blocks_tab.vue @@ -119,21 +119,16 @@
- - - {{ $t('domain_mute_card.mute') }} - - + +
`/api/v1/pleroma/statuses/${id}/reactions` const PLEROMA_EMOJI_REACT_URL = (id, emoji) => `/api/v1/pleroma/statuses/${id}/reactions/${emoji}` const PLEROMA_EMOJI_UNREACT_URL = (id, emoji) => `/api/v1/pleroma/statuses/${id}/reactions/${emoji}` @@ -995,6 +996,10 @@ const search2 = ({ credentials, q, resolve, limit, offset, following }) => { }) } +const fetchKnownDomains = ({ credentials }) => { + return promisedRequest({ url: MASTODON_KNOWN_DOMAIN_LIST_URL, credentials }) +} + const fetchDomainMutes = ({ credentials }) => { return promisedRequest({ url: MASTODON_DOMAIN_BLOCKS_URL, credentials }) } @@ -1193,6 +1198,7 @@ const apiService = { updateNotificationSettings, search2, searchUsers, + fetchKnownDomains, fetchDomainMutes, muteDomain, unmuteDomain -- cgit v1.2.3-70-g09d2 From a52a393266744560c6c6b2cbd24da812d35562fb Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 11 Jun 2020 15:22:31 +0200 Subject: NotificationUtils: Extract preparation of notification object. --- src/modules/statuses.js | 41 ++------------------- .../notification_utils/notification_utils.js | 42 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 38 deletions(-) (limited to 'src/services') diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 9a2e0df1..073b15f1 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -13,7 +13,7 @@ import { omitBy } from 'lodash' import { set } from 'vue' -import { isStatusNotification } from '../services/notification_utils/notification_utils.js' +import { isStatusNotification, prepareNotificationObject } from '../services/notification_utils/notification_utils.js' import apiService from '../services/api/api.service.js' import { muteWordHits } from '../services/status_parser/status_parser.js' @@ -344,42 +344,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot state.notifications.idStore[notification.id] = notification if ('Notification' in window && window.Notification.permission === 'granted') { - const notifObj = {} - const status = notification.status - const title = notification.from_profile.name - notifObj.icon = notification.from_profile.profile_image_url - let i18nString - switch (notification.type) { - case 'like': - i18nString = 'favorited_you' - break - case 'repeat': - i18nString = 'repeated_you' - break - case 'follow': - i18nString = 'followed_you' - break - case 'move': - i18nString = 'migrated_to' - break - case 'follow_request': - i18nString = 'follow_request' - break - } - - if (notification.type === 'pleroma:emoji_reaction') { - notifObj.body = rootGetters.i18n.t('notifications.reacted_with', [notification.emoji]) - } else if (i18nString) { - notifObj.body = rootGetters.i18n.t('notifications.' + i18nString) - } else if (isStatusNotification(notification.type)) { - notifObj.body = notification.status.text - } - - // Shows first attached non-nsfw image, if any. Should add configuration for this somehow... - if (status && status.attachments && status.attachments.length > 0 && !status.nsfw && - status.attachments[0].mimetype.startsWith('image/')) { - notifObj.image = status.attachments[0].url - } + const notifObj = prepareNotificationObject(notification, rootGetters.i18n) const reasonsToMuteNotif = ( notification.seen || @@ -393,7 +358,7 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot ) ) if (!reasonsToMuteNotif) { - let desktopNotification = new window.Notification(title, notifObj) + let desktopNotification = new window.Notification(notifObj.title, notifObj) // Chrome is known for not closing notifications automatically // according to MDN, anyway. setTimeout(desktopNotification.close.bind(desktopNotification), 5000) diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js index eb479227..4576ea83 100644 --- a/src/services/notification_utils/notification_utils.js +++ b/src/services/notification_utils/notification_utils.js @@ -43,3 +43,45 @@ export const filteredNotificationsFromStore = (store, types) => { export const unseenNotificationsFromStore = store => filter(filteredNotificationsFromStore(store), ({ seen }) => !seen) + +export const prepareNotificationObject = (notification, i18n) => { + const notifObj = {} + const status = notification.status + const title = notification.from_profile.name + notifObj.title = title + notifObj.icon = notification.from_profile.profile_image_url + let i18nString + switch (notification.type) { + case 'like': + i18nString = 'favorited_you' + break + case 'repeat': + i18nString = 'repeated_you' + break + case 'follow': + i18nString = 'followed_you' + break + case 'move': + i18nString = 'migrated_to' + break + case 'follow_request': + i18nString = 'follow_request' + break + } + + if (notification.type === 'pleroma:emoji_reaction') { + notifObj.body = i18n.t('notifications.reacted_with', [notification.emoji]) + } else if (i18nString) { + notifObj.body = i18n.t('notifications.' + i18nString) + } else if (isStatusNotification(notification.type)) { + notifObj.body = notification.status.text + } + + // Shows first attached non-nsfw image, if any. Should add configuration for this somehow... + if (status && status.attachments && status.attachments.length > 0 && !status.nsfw && + status.attachments[0].mimetype.startsWith('image/')) { + notifObj.image = status.attachments[0].url + } + + return notifObj +} -- cgit v1.2.3-70-g09d2 From 98819ae32c6f3962df955ee280cd6cc271625852 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 11 Jun 2020 15:49:39 +0200 Subject: NotificationUtils: Add tag to notifications. --- src/services/notification_utils/notification_utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/services') diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js index 4576ea83..5cc19215 100644 --- a/src/services/notification_utils/notification_utils.js +++ b/src/services/notification_utils/notification_utils.js @@ -45,7 +45,9 @@ export const unseenNotificationsFromStore = store => filter(filteredNotificationsFromStore(store), ({ seen }) => !seen) export const prepareNotificationObject = (notification, i18n) => { - const notifObj = {} + const notifObj = { + tag: notification.id + } const status = notification.status const title = notification.from_profile.name notifObj.title = title -- cgit v1.2.3-70-g09d2 From 8d7d4980b9a9c68e3c36dc00dfc85e39842b03f7 Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 11 Jun 2020 18:39:19 +0200 Subject: StatusParser: Remove unused removeAttachmentLinks. Brings down the vendor by over 200kb --- package.json | 3 +-- src/services/status_parser/status_parser.js | 15 --------------- .../specs/services/status_parser/status_parses.spec.js | 17 ----------------- 3 files changed, 1 insertion(+), 34 deletions(-) delete mode 100644 test/unit/specs/services/status_parser/status_parses.spec.js (limited to 'src/services') diff --git a/package.json b/package.json index 4d68cc6e..42efc7e9 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,10 @@ "cropperjs": "^1.4.3", "diff": "^3.0.1", "escape-html": "^1.0.3", - "karma-mocha-reporter": "^2.2.1", "localforage": "^1.5.0", "object-path": "^0.11.3", "phoenix": "^1.3.0", "portal-vue": "^2.1.4", - "sanitize-html": "^1.13.0", "v-click-outside": "^2.1.1", "vue": "^2.6.11", "vue-chat-scroll": "^1.2.1", @@ -39,6 +37,7 @@ "whatwg-fetch": "^2.0.3" }, "devDependencies": { + "karma-mocha-reporter": "^2.2.1", "@babel/core": "^7.7.5", "@babel/plugin-transform-runtime": "^7.7.6", "@babel/preset-env": "^7.7.6", diff --git a/src/services/status_parser/status_parser.js b/src/services/status_parser/status_parser.js index 3d517e3c..ed0f6d57 100644 --- a/src/services/status_parser/status_parser.js +++ b/src/services/status_parser/status_parser.js @@ -1,17 +1,4 @@ import { filter } from 'lodash' -import sanitize from 'sanitize-html' - -export const removeAttachmentLinks = (html) => { - return sanitize(html, { - allowedTags: false, - allowedAttributes: false, - exclusiveFilter: ({ tag, attribs }) => tag === 'a' && typeof attribs.class === 'string' && attribs.class.match(/attachment/) - }) -} - -export const parse = (html) => { - return removeAttachmentLinks(html) -} export const muteWordHits = (status, muteWords) => { const statusText = status.text.toLowerCase() @@ -22,5 +9,3 @@ export const muteWordHits = (status, muteWords) => { return hits } - -export default parse diff --git a/test/unit/specs/services/status_parser/status_parses.spec.js b/test/unit/specs/services/status_parser/status_parses.spec.js deleted file mode 100644 index 7afd5042..00000000 --- a/test/unit/specs/services/status_parser/status_parses.spec.js +++ /dev/null @@ -1,17 +0,0 @@ -import { removeAttachmentLinks } from '../../../../../src/services/status_parser/status_parser.js' - -const example = '' - -describe('statusParser.removeAttachmentLinks', () => { - const exampleWithoutAttachmentLinks = '' - - it('removes attachment links', () => { - const parsed = removeAttachmentLinks(example) - expect(parsed).to.eql(exampleWithoutAttachmentLinks) - }) - - it('works when the class is empty', () => { - const parsed = removeAttachmentLinks('') - expect(parsed).to.eql('') - }) -}) -- cgit v1.2.3-70-g09d2 From 0c364862991907ecd3073503af6b389c305fd53e Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 11 Jun 2020 18:49:39 +0200 Subject: API: Remove fetch polyfill All browser except IE have supported this for longer than Pleroma even exists. --- package.json | 3 +-- src/services/api/api.service.js | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src/services') diff --git a/package.json b/package.json index c131d21a..c0665f6e 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,7 @@ "vue-router": "^3.0.1", "vue-template-compiler": "^2.6.11", "vuelidate": "^0.7.4", - "vuex": "^3.0.1", - "whatwg-fetch": "^2.0.3" + "vuex": "^3.0.1" }, "devDependencies": { "karma-mocha-reporter": "^2.2.1", diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index b3082bc5..dfffc291 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -1,6 +1,5 @@ import { each, map, concat, last, get } from 'lodash' import { parseStatus, parseUser, parseNotification, parseAttachment } from '../entity_normalizer/entity_normalizer.service.js' -import 'whatwg-fetch' import { RegistrationError, StatusCodeError } from '../errors/errors' /* eslint-env browser */ -- cgit v1.2.3-70-g09d2 From 8cd5041663077a2a5dafe9c23d5495339fa31fc6 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sat, 13 Jun 2020 13:23:54 +0300 Subject: add support for defining the greentext --- src/components/settings_modal/tabs/theme_tab/theme_tab.vue | 7 +++++++ src/components/status_content/status_content.vue | 2 +- src/services/theme_data/pleromafe.js | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/services') diff --git a/src/components/settings_modal/tabs/theme_tab/theme_tab.vue b/src/components/settings_modal/tabs/theme_tab/theme_tab.vue index fcfad23b..d14f854c 100644 --- a/src/components/settings_modal/tabs/theme_tab/theme_tab.vue +++ b/src/components/settings_modal/tabs/theme_tab/theme_tab.vue @@ -256,6 +256,13 @@ :label="$t('settings.links')" /> + +

{{ $t('settings.style.advanced_colors.alert') }}

{ diff --git a/src/services/theme_data/pleromafe.js b/src/services/theme_data/pleromafe.js index 0c1fe543..b577cfab 100644 --- a/src/services/theme_data/pleromafe.js +++ b/src/services/theme_data/pleromafe.js @@ -356,6 +356,12 @@ export const SLOT_INHERITANCE = { textColor: 'preserve' }, + postGreentext: { + depends: ['cGreen'], + layer: 'bg', + textColor: 'preserve' + }, + border: { depends: ['fg'], opacity: 'border', -- cgit v1.2.3-70-g09d2 From d41c9a717ca3f52b0a67bbb2b0ab8b0c898bba4b Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 14 Jun 2020 13:16:08 +0200 Subject: Polls: Construct an html field during normalization. --- src/components/poll/poll.vue | 8 +++++++- src/services/entity_normalizer/entity_normalizer.service.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src/services') diff --git a/src/components/poll/poll.vue b/src/components/poll/poll.vue index 56e91cca..28f90006 100644 --- a/src/components/poll/poll.vue +++ b/src/components/poll/poll.vue @@ -17,7 +17,7 @@ {{ percentageForOption(option.votes_count) }}% - {{ option.title }} +
{ output.summary_html = addEmojis(escape(data.spoiler_text), data.emojis) output.external_url = data.url output.poll = data.poll + if (output.poll) { + output.poll.options = (output.poll.options || []).map(field => { + field.title_html = addEmojis(field.title, data.emojis) + return field + }) + } output.pinned = data.pinned output.muted = data.muted } else { -- cgit v1.2.3-70-g09d2 From 72ee51c85c9ab74de2009b90cfd7e3e50a2e00af Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 14 Jun 2020 13:09:14 +0000 Subject: Apply suggestion to src/services/entity_normalizer/entity_normalizer.service.js --- src/services/entity_normalizer/entity_normalizer.service.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/services') diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index e93eea5b..883e7a02 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -259,10 +259,10 @@ export const parseStatus = (data) => { output.external_url = data.url output.poll = data.poll if (output.poll) { - output.poll.options = (output.poll.options || []).map(field => { - field.title_html = addEmojis(field.title, data.emojis) - return field - }) + output.poll.options = (output.poll.options || []).map(field => ({ + ...field, + title_html: addEmojis(field.title, data.emojis) + })) } output.pinned = data.pinned output.muted = data.muted -- cgit v1.2.3-70-g09d2 From 580fcd3ad9508befbe93658c2ee7a4e8d776db4b Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 17 Jun 2020 18:26:06 +0300 Subject: restyle the fields --- src/components/user_profile/user_profile.vue | 22 ++++++++++++++++------ .../entity_normalizer/entity_normalizer.service.js | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src/services') diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index 0c36f2e2..2892a121 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -133,12 +133,14 @@