diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 08c00c641f..505005825d 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -24,10 +24,6 @@ const afterStoreSetup = ({ store, i18n }) => { store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(uploadlimit.bannerlimit) }) } - if (data.nsfwCensorImage) { - store.dispatch('setInstanceOption', { name: 'nsfwCensorImage', value: data.nsfwCensorImage }) - } - if (vapidPublicKey) { store.dispatch('setInstanceOption', { name: 'vapidPublicKey', value: vapidPublicKey }) } @@ -54,46 +50,44 @@ const afterStoreSetup = ({ store, i18n }) => { config = Object.assign({}, staticConfig, apiConfig) } - var theme = (config.theme) - var background = (config.background) - var hidePostStats = (config.hidePostStats) - var hideUserStats = (config.hideUserStats) - var logo = (config.logo) - var logoMask = (typeof config.logoMask === 'undefined' ? true : config.logoMask) - var logoMargin = (typeof config.logoMargin === 'undefined' ? 0 : config.logoMargin) - var redirectRootNoLogin = (config.redirectRootNoLogin) - var redirectRootLogin = (config.redirectRootLogin) - var chatDisabled = (config.chatDisabled) - var showInstanceSpecificPanel = (config.showInstanceSpecificPanel) - var scopeOptionsEnabled = (config.scopeOptionsEnabled) - var formattingOptionsEnabled = (config.formattingOptionsEnabled) - var collapseMessageWithSubject = (config.collapseMessageWithSubject) - var loginMethod = (config.loginMethod) - var scopeCopy = (config.scopeCopy) - var subjectLineBehavior = (config.subjectLineBehavior) - var alwaysShowSubjectInput = (config.alwaysShowSubjectInput) - var noAttachmentLinks = (config.noAttachmentLinks) + const copyInstanceOption = (name) => { + store.dispatch('setInstanceOption', {name, value: config[name]}) + } - store.dispatch('setInstanceOption', { name: 'theme', value: theme }) - store.dispatch('setInstanceOption', { name: 'background', value: background }) - store.dispatch('setInstanceOption', { name: 'hidePostStats', value: hidePostStats }) - store.dispatch('setInstanceOption', { name: 'hideUserStats', value: hideUserStats }) - store.dispatch('setInstanceOption', { name: 'logo', value: logo }) - store.dispatch('setInstanceOption', { name: 'logoMask', value: logoMask }) - store.dispatch('setInstanceOption', { name: 'logoMargin', value: logoMargin }) - store.dispatch('setInstanceOption', { name: 'redirectRootNoLogin', value: redirectRootNoLogin }) - store.dispatch('setInstanceOption', { name: 'redirectRootLogin', value: redirectRootLogin }) - store.dispatch('setInstanceOption', { name: 'showInstanceSpecificPanel', value: showInstanceSpecificPanel }) - store.dispatch('setInstanceOption', { name: 'scopeOptionsEnabled', value: scopeOptionsEnabled }) - store.dispatch('setInstanceOption', { name: 'formattingOptionsEnabled', value: formattingOptionsEnabled }) - store.dispatch('setInstanceOption', { name: 'collapseMessageWithSubject', value: collapseMessageWithSubject }) - store.dispatch('setInstanceOption', { name: 'loginMethod', value: loginMethod }) - store.dispatch('setInstanceOption', { name: 'scopeCopy', value: scopeCopy }) - store.dispatch('setInstanceOption', { name: 'subjectLineBehavior', value: subjectLineBehavior }) - store.dispatch('setInstanceOption', { name: 'alwaysShowSubjectInput', value: alwaysShowSubjectInput }) - store.dispatch('setInstanceOption', { name: 'noAttachmentLinks', value: noAttachmentLinks }) + copyInstanceOption('nsfwCensorImage') + copyInstanceOption('theme') + copyInstanceOption('background') + copyInstanceOption('hidePostStats') + copyInstanceOption('hideUserStats') + copyInstanceOption('logo') - if (chatDisabled) { + store.dispatch('setInstanceOption', { + name: 'logoMask', + value: typeof config.logoMask === 'undefined' + ? true + : config.logoMask + }) + + store.dispatch('setInstanceOption', { + name: 'logoMargin', + value: typeof config.logoMargin === 'undefined' + ? 0 + : config.logoMargin + }) + + copyInstanceOption('redirectRootNoLogin') + copyInstanceOption('redirectRootLogin') + copyInstanceOption('showInstanceSpecificPanel') + copyInstanceOption('scopeOptionsEnabled') + copyInstanceOption('formattingOptionsEnabled') + copyInstanceOption('collapseMessageWithSubject') + copyInstanceOption('loginMethod') + copyInstanceOption('scopeCopy') + copyInstanceOption('subjectLineBehavior') + copyInstanceOption('alwaysShowSubjectInput') + copyInstanceOption('noAttachmentLinks') + + if ((config.chatDisabled)) { store.dispatch('disableChat') } diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 0ae8f71a41..4793985249 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -14,7 +14,7 @@ const Attachment = { ], data () { return { - nsfwImage: this.$store.state.config.nsfwCensorImage || nsfwImage, + nsfwImage: this.$store.state.instance.nsfwCensorImage || nsfwImage, hideNsfwLocal: this.$store.state.config.hideNsfw, preloadImage: this.$store.state.config.preloadImage, loading: false, diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 56a49d2d37..5a80db8ad7 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -27,7 +27,7 @@ :href="attachment.url" target="_blank" :title="attachment.description" > - + { + const seqA = Number(a.id) + const seqB = Number(b.id) + const isSeqA = !Number.isNaN(seqA) + const isSeqB = !Number.isNaN(seqB) + if (isSeqA && isSeqB) { + return seqA < seqB ? -1 : 1 + } else if (isSeqA && !isSeqB) { + return 1 + } else if (!isSeqA && isSeqB) { + return -1 + } else { + return a.id < b.id ? -1 : 1 + } +} + const sortAndFilterConversation = (conversation) => { - conversation = filter(conversation, (status) => statusType(status) !== 'retweet') - return sortBy(conversation, 'id') + conversation = filter(conversation, (status) => status.type !== 'retweet') + return conversation.filter(_ => _).sort(sortById) } const conversation = { @@ -18,10 +33,12 @@ const conversation = { 'collapsable' ], computed: { - status () { return this.statusoid }, + status () { + return this.statusoid + }, conversation () { if (!this.status) { - return false + return [] } const conversationId = this.status.statusnet_conversation_id @@ -32,7 +49,9 @@ const conversation = { replies () { let i = 1 return reduce(this.conversation, (result, {id, in_reply_to_status_id}) => { - const irid = Number(in_reply_to_status_id) + /* eslint-disable camelcase */ + const irid = in_reply_to_status_id + /* eslint-enable camelcase */ if (irid) { result[irid] = result[irid] || [] result[irid].push({ @@ -69,7 +88,6 @@ const conversation = { } }, getReplies (id) { - id = Number(id) return this.replies[id] || [] }, focused (id) { @@ -80,7 +98,7 @@ const conversation = { } }, setHighlight (id) { - this.highlight = Number(id) + this.highlight = id } } } diff --git a/src/components/status/status.js b/src/components/status/status.js index 1db074e21a..2d48561601 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -76,6 +76,14 @@ const Status = { return (this.$store.state.config.hideAttachments && !this.inConversation) || (this.$store.state.config.hideAttachmentsInConv && this.inConversation) }, + userProfileLink () { + return this.generateUserProfileLink(this.status.user.id, this.status.user.screen_name) + }, + replyProfileLink () { + if (this.isReply) { + return this.generateUserProfileLink(this.status.in_reply_to_status_id, this.replyToName) + } + }, retweet () { return !!this.statusoid.retweeted_status }, retweeter () { return this.statusoid.user.name }, retweeterHtml () { return this.statusoid.user.name_html }, @@ -122,6 +130,14 @@ const Status = { isReply () { return !!this.status.in_reply_to_status_id }, + replyToName () { + const user = this.$store.state.users.usersObject[this.status.in_reply_to_user_id] + if (user) { + return user.screen_name + } else { + return this.status.in_reply_to_screen_name + } + }, hideReply () { if (this.$store.state.config.replyVisibility === 'all') { return false @@ -132,7 +148,7 @@ const Status = { if (this.status.user.id === this.$store.state.users.currentUser.id) { return false } - if (this.status.activity_type === 'repeat') { + if (this.status.type === 'retweet') { return false } var checkFollowing = this.$store.state.config.replyVisibility === 'following' @@ -281,7 +297,7 @@ const Status = { }, replyEnter (id, event) { this.showPreview = true - const targetId = Number(id) + const targetId = id const statuses = this.$store.state.statuses.allStatuses if (!this.preview) { @@ -300,7 +316,7 @@ const Status = { replyLeave () { this.showPreview = false }, - userProfileLink (id, name) { + generateUserProfileLink (id, name) { return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames) }, setMedia () { @@ -310,7 +326,6 @@ const Status = { }, watch: { 'highlight': function (id) { - id = Number(id) if (this.status.id === id) { let rect = this.$el.getBoundingClientRect() if (rect.top < 100) { diff --git a/src/components/status/status.vue b/src/components/status/status.vue index ba3b9a4a38..c1800d6466 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -3,7 +3,7 @@