From 7ed9d17ce745abc38a27d4994452a136357aba46 Mon Sep 17 00:00:00 2001 From: shpuld Date: Sun, 7 Jul 2019 23:02:09 +0300 Subject: Add thread muting to context menu of status --- src/components/extra_buttons/extra_buttons.js | 15 ++++++++++++--- src/components/extra_buttons/extra_buttons.vue | 16 +++++++++++++++- src/i18n/en.json | 4 +++- src/i18n/fi.json | 9 ++++++++- src/modules/statuses.js | 12 ++++++++++++ src/services/api/api.service.js | 14 ++++++++++++++ .../backend_interactor_service.js | 4 ++++ .../entity_normalizer/entity_normalizer.service.js | 1 + 8 files changed, 69 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/components/extra_buttons/extra_buttons.js b/src/components/extra_buttons/extra_buttons.js index 528da301..56b2c41e 100644 --- a/src/components/extra_buttons/extra_buttons.js +++ b/src/components/extra_buttons/extra_buttons.js @@ -34,6 +34,18 @@ const ExtraButtons = { .then(() => this.$emit('onSuccess')) .catch(err => this.$emit('onError', err.error.error)) }, + muteConversation () { + this.refreshPopper() + this.$store.dispatch('muteConversation', this.status.id) + .then(() => this.$emit('onSuccess')) + .catch(err => this.$emit('onError', err.error.error)) + }, + unmuteConversation () { + this.refreshPopper() + this.$store.dispatch('unmuteConversation', this.status.id) + .then(() => this.$emit('onSuccess')) + .catch(err => this.$emit('onError', err.error.error)) + }, refreshPopper () { this.showPopper = false this.showDropDown = false @@ -54,9 +66,6 @@ const ExtraButtons = { }, canPin () { return this.ownStatus && (this.status.visibility === 'public' || this.status.visibility === 'unlisted') - }, - enabled () { - return this.canPin || this.canDelete } } } diff --git a/src/components/extra_buttons/extra_buttons.vue b/src/components/extra_buttons/extra_buttons.vue index 8e24e9a5..5027be1b 100644 --- a/src/components/extra_buttons/extra_buttons.vue +++ b/src/components/extra_buttons/extra_buttons.vue @@ -1,6 +1,6 @@ - +
-- cgit v1.2.3-70-g09d2 From 53c9517a4aeae1158a95e3b9c6d6d89e3a7e0ee9 Mon Sep 17 00:00:00 2001 From: taehoon Date: Wed, 24 Jul 2019 22:42:06 -0400 Subject: use array.includes instead of array.indexOf --- src/components/timeline/timeline.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index b1413591..a5c6418b 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -46,7 +46,7 @@ const Timeline = { const result = {} if (this.pinnedStatusIds && this.pinnedStatusIds.length > 0) { for (let status of this.timeline.visibleStatuses) { - if (this.pinnedStatusIds.indexOf(status.id) === -1) { + if (!this.pinnedStatusIds.includes(status.id)) { break } result[status.id] = true -- cgit v1.2.3-70-g09d2 From 65ef03931661561db0791ee7d560292dda6b7d48 Mon Sep 17 00:00:00 2001 From: taehoon Date: Thu, 25 Jul 2019 08:03:41 -0400 Subject: add unit test for elimination logic --- src/components/timeline/timeline.js | 28 +++++++++++++++++----------- test/unit/specs/components/timeline.spec.js | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 test/unit/specs/components/timeline.spec.js (limited to 'src') diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index a5c6418b..aac3869f 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -1,7 +1,20 @@ import Status from '../status/status.vue' import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.service.js' import Conversation from '../conversation/conversation.vue' -import { throttle } from 'lodash' +import { throttle, keyBy } from 'lodash' + +export const getExcludedStatusIdsByPinning = (statuses, pinnedStatusIds) => { + const ids = [] + if (pinnedStatusIds && pinnedStatusIds.length > 0) { + for (let status of statuses) { + if (!pinnedStatusIds.includes(status.id)) { + break + } + ids.push(status.id) + } + } + return ids +} const Timeline = { props: [ @@ -43,16 +56,9 @@ const Timeline = { }, // id map of statuses which need to be hidden in the main list due to pinning logic excludedStatusIdsObject () { - const result = {} - if (this.pinnedStatusIds && this.pinnedStatusIds.length > 0) { - for (let status of this.timeline.visibleStatuses) { - if (!this.pinnedStatusIds.includes(status.id)) { - break - } - result[status.id] = true - } - } - return result + const ids = getExcludedStatusIdsByPinning(this.timeline.visibleStatuses, this.pinnedStatusIds) + // Convert id array to object + return keyBy(ids, id => id) } }, components: { diff --git a/test/unit/specs/components/timeline.spec.js b/test/unit/specs/components/timeline.spec.js new file mode 100644 index 00000000..b13d3e20 --- /dev/null +++ b/test/unit/specs/components/timeline.spec.js @@ -0,0 +1,17 @@ +import { getExcludedStatusIdsByPinning } from 'src/components/timeline/timeline.js' +import { difference } from 'lodash' + +describe('Timeline', () => { + describe('getExcludedStatusIdsByPinning', () => { + it('should not return unpinned status ids', () => { + const statuses = [ + { id: 1 }, + { id: 2 }, + { id: 3 }, + { id: 4 } + ] + const pinnedStatusIds = [1, 3] + expect(difference(getExcludedStatusIdsByPinning(statuses, pinnedStatusIds), pinnedStatusIds)).to.eql([]) + }) + }) +}) \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 7c2982064e6faf60c95e909e7722d6110310055a Mon Sep 17 00:00:00 2001 From: taehoon Date: Mon, 22 Jul 2019 16:58:20 -0400 Subject: enlarge avatar in profile page --- src/components/user_card/user_card.js | 14 ++++++++++++++ src/components/user_card/user_card.vue | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index e019ebbd..a3c962fb 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -5,6 +5,7 @@ import ModerationTools from '../moderation_tools/moderation_tools.vue' import { hex2rgb } from '../../services/color_convert/color_convert.js' import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' +import { isEqual } from 'lodash' export default { props: [ 'user', 'switcher', 'selected', 'hideBio', 'rounded', 'bordered' ], @@ -100,6 +101,11 @@ export default { const validRole = rights.admin || rights.moderator const roleTitle = rights.admin ? 'admin' : 'moderator' return validRole && roleTitle + }, + isActiveRoute () { + const profileRoute = this.userProfileLink(this.user) + const currentRoute = this.$router.currentRoute + return profileRoute.name === currentRoute.name && isEqual(profileRoute.params, currentRoute.params) } }, components: { @@ -162,6 +168,14 @@ export default { }, reportUser () { this.$store.dispatch('openUserReportingModal', this.user.id) + }, + enlargeAvatar () { + const attachment = { + url: this.user.profile_image_url_original, + mimetype: 'image' + } + this.$store.dispatch('setMedia', [attachment]) + this.$store.dispatch('setCurrent', attachment) } } } diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index 9e142480..3c0bf0d4 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -7,7 +7,20 @@