move SABs margin into status

This commit is contained in:
Henry Jameson 2026-07-10 17:09:17 +03:00
commit 3db36c25ee
18 changed files with 235 additions and 44 deletions

View file

@ -1,3 +1,4 @@
import { find } from 'lodash'
import { mapState as mapPiniaState } from 'pinia' import { mapState as mapPiniaState } from 'pinia'
import { mapState } from 'vuex' import { mapState } from 'vuex'
@ -7,6 +8,8 @@ import Gallery from 'src/components/gallery/gallery.vue'
import LinkPreview from 'src/components/link-preview/link-preview.vue' import LinkPreview from 'src/components/link-preview/link-preview.vue'
import Popover from 'src/components/popover/popover.vue' import Popover from 'src/components/popover/popover.vue'
import StatusContent from 'src/components/status_content/status_content.vue' import StatusContent from 'src/components/status_content/status_content.vue'
import StatusBody from 'src/components/status_body/status_body.vue'
import StatusActionButtons from 'src/components/status_action_buttons/status_action_buttons.vue'
import UserAvatar from 'src/components/user_avatar/user_avatar.vue' import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
import UserPopover from 'src/components/user_popover/user_popover.vue' import UserPopover from 'src/components/user_popover/user_popover.vue'
@ -25,18 +28,19 @@ library.add(faTimes, faEllipsisH, faCircleNotch)
const ChatMessage = { const ChatMessage = {
name: 'ChatMessage', name: 'ChatMessage',
props: ['edited', 'noHeading', 'chatItem', 'hoveredMessageChain'], props: ['edited', 'noHeading', 'previousItem', 'chatItem', 'previousItem', 'hoveredMessageChain'],
emits: ['hover'], emits: ['hover', 'replyRequested'],
components: { components: {
Popover, Popover,
Attachment, Attachment,
StatusContent, StatusContent,
StatusBody,
StatusActionButtons,
UserAvatar, UserAvatar,
Gallery, Gallery,
LinkPreview, LinkPreview,
ChatMessageDate, ChatMessageDate,
UserPopover, UserPopover,},
},
computed: { computed: {
// Returns HH:MM (hours and minutes) in local time. // Returns HH:MM (hours and minutes) in local time.
createdAt() { createdAt() {
@ -65,6 +69,16 @@ const ChatMessage = {
isMessage() { isMessage() {
return this.chatItem.type === 'message' return this.chatItem.type === 'message'
}, },
isCustomReply() {
if (!this.previousItem) return false
console.log('==')
console.log('PREV', toValue(this.previousItem.data.raw_html))
console.log('CURR', toValue(this.chatItem.data.raw_html))
return this.previousItem.data.id !== this.chatItem.data.in_reply_to_status_id
},
customReplyTo() {
return find(this.$store.state.statuses.allStatuses, { id: this.chatItem.data.in_reply_to_status_id })
},
messageForStatusContent() { messageForStatusContent() {
return { return {
summary: '', summary: '',

View file

@ -11,22 +11,53 @@
} }
} }
.chat-message-menu { .chat-message-toolbar {
transition: opacity 0.1s; transition: opacity 0.1s;
opacity: 0; opacity: 0;
position: absolute; position: absolute;
top: -0.8em; top: -0.8em;
right: 0.4rem;
z-index: 10;
button { .quick-action-buttons {
justify-items: end;
grid-template-columns: auto auto auto;
}
.simple-button {
padding-top: 0.2em; padding-top: 0.2em;
padding-bottom: 0.2em; padding-bottom: 0.2em;
} }
&.-visible {
opacity: 1;
}
} }
.menu-icon { .menu-icon {
cursor: pointer; cursor: pointer;
} }
.reply-to-header {
white-space: nowrap;
width: 100%;
display: flex;
align-items: baseline;
gap: 0.5em;
.reply-label {
display: inline-block;
line-height: 1;
}
.reply-body {
line-height: 1;
display: inline-block;
overflow-x: hidden;
text-overflow: ellipsis;
}
}
.popover { .popover {
width: 12em; width: 12em;
} }
@ -66,7 +97,6 @@
font-size: 0.8em; font-size: 0.8em;
margin: -1em 0 -0.5em; margin: -1em 0 -0.5em;
font-style: italic; font-style: italic;
opacity: 0.8;
} }
.without-attachment { .without-attachment {
@ -112,14 +142,8 @@
align-items: flex-end; align-items: flex-end;
} }
.chat-message-menu { .reply-to-header {
right: 0.4rem; justify-content: end;
}
}
.-incoming {
.chat-message-menu {
left: 0.4rem;
} }
} }

View file

@ -25,6 +25,25 @@
</UserPopover> </UserPopover>
</div> </div>
<div class="chat-message-inner"> <div class="chat-message-inner">
<small
v-if="isStatus && isCustomReply"
class="reply-to-header faint"
>
<strong class="reply-label">
<FAIcon
class="fa-scale-110 fa-old-padding"
icon="reply"
flip="horizontal"
/>
{{ $t('status.reply_to') }}
</strong>
<StatusBody
class="reply-body"
:status="customReplyTo"
collapse
single-line
/>
</small>
<div <div
class="status-body" class="status-body"
:style="{ 'min-width': message.attachment ? '80%' : '' }" :style="{ 'min-width': message.attachment ? '80%' : '' }"
@ -36,15 +55,27 @@
@mouseenter="hovered = true" @mouseenter="hovered = true"
@mouseleave="hovered = false" @mouseleave="hovered = false"
> >
<StatusActionButtons
v-if="isStatus"
class="chat-message-toolbar"
:class="{ '-visible': hovered || menuOpened }"
:status="message"
:pinned="new Set(['reply', 'emoji'])"
fixed-pinned
use-default-buttons
hide-labels
@toggle-replying="$emit('replyRequested', message)"
/>
<div <div
class="chat-message-menu" class="chat-message-toolbar"
:class="{ 'visible': hovered || menuOpened }" :class="{ '-visible': hovered || menuOpened }"
v-else
> >
<Popover <Popover
trigger="click" trigger="click"
:trigger-attrs="{ 'class': 'button-default menu-icon simple-button', title: $t('chats.more') }"
placement="top" placement="top"
bound-to-selector=".chat-view-inner"
:bound-to="{ x: 'container' }"
:margin="popoverMarginStyle" :margin="popoverMarginStyle"
@show="menuOpened = true" @show="menuOpened = true"
@close="menuOpened = false" @close="menuOpened = false"
@ -62,12 +93,7 @@
</div> </div>
</template> </template>
<template #trigger> <template #trigger>
<button
class="button-default menu-icon"
:title="$t('chats.more')"
>
<FAIcon icon="ellipsis-h" /> <FAIcon icon="ellipsis-h" />
</button>
</template> </template>
</Popover> </Popover>
</div> </div>
@ -87,9 +113,9 @@
:title="visibilityLocalized" :title="visibilityLocalized"
> >
<FAIcon <FAIcon
fixed-width
class="fa-scale-110" class="fa-scale-110"
:icon="visibilityIcon(message.visibility)" :icon="visibilityIcon(message.visibility)"
fixed-width
/> />
</span> </span>
<span <span
@ -98,8 +124,8 @@
> >
<FAIcon <FAIcon
class="fa-old-padding" class="fa-old-padding"
spin
icon="circle-notch" icon="circle-notch"
spin
/> />
</span> </span>
{{ createdAt }} {{ createdAt }}

View file

@ -20,7 +20,7 @@ const ChatMessageList = {
hoveredMessageChainId: undefined, hoveredMessageChainId: undefined,
} }
}, },
emits: ['messageDelete'], emits: ['messageDelete', 'replyRequested'],
computed: { computed: {
chatItems() { chatItems() {
const messages = [ const messages = [
@ -107,6 +107,22 @@ const ChatMessageList = {
onMessageDelete({ messageId, chatId }) { onMessageDelete({ messageId, chatId }) {
this.$emit('messageDelete', { messageId, chatId }) this.$emit('messageDelete', { messageId, chatId })
}, },
onReplyRequested(message) {
this.$emit('replyRequested', message)
},
getPreviousItem(index) {
let result
this.chatItems.slice(0, index).reverse().some((item) => {
const isMessage = item.type === 'message'
if (isMessage) {
result = item
}
return isMessage
})
return result
}
}, },
} }

View file

@ -1,12 +1,14 @@
<template> <template>
<div class="ChatMessageList"> <div class="ChatMessageList">
<ChatMessage <ChatMessage
v-for="chatItem in chatItems" v-for="(chatItem, index) in chatItems"
:key="chatItem.id" :key="chatItem.id"
:chat-item="chatItem" :chat-item="chatItem"
:previous-item="getPreviousItem(index)"
:hovered-message-chain="chatItem.messageChainId === hoveredMessageChainId" :hovered-message-chain="chatItem.messageChainId === hoveredMessageChainId"
@hover="onMessageHover" @hover="onMessageHover"
@delete="onMessageDelete" @delete="onMessageDelete"
@reply-requested="onReplyRequested"
/> />
</div> </div>
</template> </template>

View file

@ -2,6 +2,7 @@ import { clone, filter, findIndex, get, reduce } from 'lodash'
import { mapState as mapPiniaState } from 'pinia' import { mapState as mapPiniaState } from 'pinia'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import StatusContent from 'src/components/status_content/status_content.vue'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import ChatMessageList from 'src/components/chat_message_list/chat_message_list.vue' import ChatMessageList from 'src/components/chat_message_list/chat_message_list.vue'
import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue' import QuickFilterSettings from 'src/components/quick_filter_settings/quick_filter_settings.vue'
@ -20,9 +21,11 @@ import {
faAngleDoubleDown, faAngleDoubleDown,
faAngleDoubleLeft, faAngleDoubleLeft,
faChevronLeft, faChevronLeft,
faReply,
faTimes,
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
library.add(faAngleDoubleDown, faAngleDoubleLeft, faChevronLeft) library.add(faAngleDoubleDown, faAngleDoubleLeft, faChevronLeft, faReply, faTimes)
const sortById = (a, b) => { const sortById = (a, b) => {
const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id
@ -105,6 +108,7 @@ const conversation = {
inlineDivePosition: null, inlineDivePosition: null,
loadStatusError: null, loadStatusError: null,
unsuspendibleIds: new Set(), unsuspendibleIds: new Set(),
explicitReplyStatus: null,
} }
}, },
created() { created() {
@ -121,9 +125,11 @@ const conversation = {
return maxDepth >= 1 ? maxDepth : 1 return maxDepth >= 1 ? maxDepth : 1
}, },
lastStatus() { lastStatus() {
console.log('LAST STATUS', this.conversation[this.conversation.length - 1])
return this.conversation[this.conversation.length - 1] return this.conversation[this.conversation.length - 1]
}, },
replyStatus() {
return this.explicitReplyStatus ?? this.lastStatus
},
streamingEnabled() { streamingEnabled() {
return ( return (
this.mergedConfig.useStreamingApi && this.mergedConfig.useStreamingApi &&
@ -415,6 +421,7 @@ const conversation = {
QuickViewSettings, QuickViewSettings,
ChatMessageList, ChatMessageList,
PostStatusForm, PostStatusForm,
StatusContent,
}, },
watch: { watch: {
statusId(newVal, oldVal) { statusId(newVal, oldVal) {

View file

@ -93,8 +93,31 @@
} }
} }
.auto-reply-to-section {
margin: 0 1em;
gap: 0.5em;
h4 {
margin: 0.5em 0;
line-height: 1.5;
button {
line-height: 1.5;
}
}
.reply-to-preview {
display: flex;
align-items: center;
gap: 0.5em;
}
}
.chat-view-reply-form { .chat-view-reply-form {
position: sticky; position: sticky;
display: flex;
flex-direction: column;
align-items: stretch;
bottom: 0; bottom: 0;
} }
} }

View file

@ -202,22 +202,50 @@
> >
<ChatMessageList <ChatMessageList
:messages="conversation" :messages="conversation"
@reply-requested="e => explicitReplyStatus = e"
/> />
</div> </div>
</div> </div>
<div <div
v-if="isChatView && isExpanded" v-if="isChatView && isExpanded && replyStatus"
class="chat-view-reply-form panel-footer -flexible-height" class="chat-view-reply-form panel-footer -flexible-height"
> >
<div class="auto-reply-to-section">
<h4
class="reply-to-text"
>
{{ explicitReplyStatus ? $t('status.reply_to_selected') : $t('status.reply_to_last') }}
<button
v-if="explicitReplyStatus"
class="button-default"
@click="explicitReplyStatus = null"
>
<FAIcon icon="times" />
{{ $t('general.cancel') }}
</button>
</h4>
<div class="reply-to-preview">
<FAIcon
icon="reply"
flip="horizontal"
/>
<StatusContent
:status="replyStatus"
compact
collapse
/>
</div>
</div>
<PostStatusForm <PostStatusForm
:submit-on-enter="!mobileLayout" :submit-on-enter="!mobileLayout"
:preserve-focus="!mobileLayout" :preserve-focus="!mobileLayout"
:auto-focus="!mobileLayout" :auto-focus="!mobileLayout"
:reply-to="lastStatus.id" :reply-to="replyStatus.id"
:disable-quotes="true" :disable-quotes="true"
:copy-message-scope="lastStatus.visibility" :copy-message-scope="replyStatus.visibility"
:attentions="lastStatus.attentions" :attentions="replyStatus.attentions"
:replied-user="lastStatus.user" :replied-user="replyStatus.user"
force-mentions-line
/> />
</div> </div>
</div> </div>

View file

@ -385,4 +385,8 @@
text-decoration: underline; text-decoration: underline;
} }
} }
.status-action-buttons {
margin-top: var(--status-margin);
}
} }

View file

@ -512,6 +512,7 @@
<StatusActionButtons <StatusActionButtons
v-if="!noHeading && !isPreview" v-if="!noHeading && !isPreview"
class="status-action-buttons"
:status="status" :status="status"
:replying="replying" :replying="replying"
@toggle-replying="toggleReplyForm" @toggle-replying="toggleReplyForm"

View file

@ -69,6 +69,8 @@ export default {
'getComponent', 'getComponent',
'doAction', 'doAction',
'outerClose', 'outerClose',
'defaultButtonStyle',
'hideLabel',
], ],
components: { components: {
StatusBookmarkFolderMenu, StatusBookmarkFolderMenu,
@ -103,11 +105,12 @@ export default {
return useMergedConfigStore().mergedConfig.hidePostStats return useMergedConfigStore().mergedConfig.hidePostStats
}, },
buttonInnerClass() { buttonInnerClass() {
const buttonStyleClass = this.defaultButtonStyle ? 'button-default' : 'button-unstyled'
return [ return [
this.button.name + '-button', this.button.name + '-button',
{ {
'main-button': this.extra, 'main-button': this.extra,
'button-unstyled': !this.extra, [buttonStyleClass]: !this.extra,
'-active': this.button.active?.(this.funcArg), '-active': this.button.active?.(this.funcArg),
disabled: this.button.interactive disabled: this.button.interactive
? !this.button.interactive(this.funcArg) ? !this.button.interactive(this.funcArg)

View file

@ -60,7 +60,7 @@
/> />
</component> </component>
<span <span
v-if="!hidePostStats && button.counter?.(funcArg) > 0" v-if="!hidePostStats && button.counter?.(funcArg) > 0 && !hideLabel"
class="action-counter" class="action-counter"
> >
{{ button.counter?.(funcArg) }} {{ button.counter?.(funcArg) }}

View file

@ -42,7 +42,7 @@ export default {
), ),
), ),
}, },
props: ['button', 'status'], props: ['button', 'status', 'defaultButton','hideLabel'],
emits: ['emojiPickerShown'], emits: ['emojiPickerShown'],
mounted() { mounted() {
if (this.button.name === 'mute') { if (this.button.name === 'mute') {

View file

@ -10,6 +10,7 @@
<ActionButton <ActionButton
:button="button" :button="button"
:status="status" :status="status"
:hide-label="hideLabel"
v-bind.prop="$attrs" v-bind.prop="$attrs"
/> />
</template> </template>
@ -131,6 +132,7 @@
v-else v-else
:button="button" :button="button"
:status="status" :status="status"
:hide-label="hideLabel"
v-bind="$attrs" v-bind="$attrs"
@emoji-picker-shown="e => $emit('emojiPickerShown', e)" @emoji-picker-shown="e => $emit('emojiPickerShown', e)"
/> />

View file

@ -15,7 +15,31 @@ import { faEllipsisH } from '@fortawesome/free-solid-svg-icons'
library.add(faEllipsisH) library.add(faEllipsisH)
const StatusActionButtons = { const StatusActionButtons = {
props: ['status', 'replying'], props: {
status: {
type: Object,
required: true,
},
replying: {
type: Boolean,
default: false,
},
fixedPinned: {
type: Boolean,
default: false,
},
pinned: {
type: Set,
},
useDefaultButtons: {
type: Boolean,
default: false,
},
hideLabels: {
type: Boolean,
default: false,
}
},
emits: ['toggleReplying', 'onSuccess', 'onError'], emits: ['toggleReplying', 'onSuccess', 'onError'],
data() { data() {
return { return {
@ -36,14 +60,19 @@ const StatusActionButtons = {
ConfirmModal: defineAsyncComponent( ConfirmModal: defineAsyncComponent(
() => import('src/components/confirm_modal/confirm_modal.vue'), () => import('src/components/confirm_modal/confirm_modal.vue'),
), ),
ActionButtonContainer, ActionButtonContainer,
}, },
computed: { computed: {
...mapState(useSyncConfigStore, { ...mapState(useSyncConfigStore, {
pinnedItems: (store) => userPinnedItems: (store) => new Set(store.prefsStorage.collections.pinnedStatusActions),
new Set(store.prefsStorage.collections.pinnedStatusActions),
}), }),
pinnedItems() {
if (this.fixedPinned) {
return this.pinned
} else {
return this.userPinnedItems
}
},
buttons() { buttons() {
return BUTTONS.filter((x) => (x.if ? x.if(this.funcArg) : true)) return BUTTONS.filter((x) => (x.if ? x.if(this.funcArg) : true))
}, },

View file

@ -8,7 +8,6 @@
grid-auto-flow: row dense; grid-auto-flow: row dense;
grid-auto-rows: 1fr; grid-auto-rows: 1fr;
grid-gap: 0.5em 0.1em; grid-gap: 0.5em 0.1em;
margin-top: var(--status-margin);
} }
.pin-action-button { .pin-action-button {
@ -17,6 +16,12 @@
padding: 0.5em; padding: 0.5em;
margin: 0; margin: 0;
} }
.quick-action.popover-wrapper {
button {
padding: 0
}
}
} }
// popover // popover
.extra-action-buttons { .extra-action-buttons {

View file

@ -21,6 +21,8 @@
:close="() => { /* no-op */ }" :close="() => { /* no-op */ }"
:do-action="doAction" :do-action="doAction"
@emoji-picker-shown="onEmojiPickerShown" @emoji-picker-shown="onEmojiPickerShown"
:default-button-style="useDefaultButtons"
:hide-label="hideLabels"
/> />
<button <button
v-if="showPin && currentUser" v-if="showPin && currentUser"
@ -40,6 +42,7 @@
<Popover <Popover
trigger="click" trigger="click"
:trigger-attrs="triggerAttrs" :trigger-attrs="triggerAttrs"
:normal-button="useDefaultButtons"
class="quick-action" class="quick-action"
:tabindex="0" :tabindex="0"
placement="bottom" placement="bottom"
@ -75,6 +78,8 @@
:get-component="getComponent" :get-component="getComponent"
:outer-close="close" :outer-close="close"
:do-action="doAction" :do-action="doAction"
:default-button-style="useDefaultButtons"
:hide-label="hideLabels"
/> />
<button <button
v-if="showPin && currentUser" v-if="showPin && currentUser"

View file

@ -1654,6 +1654,8 @@
"delete_confirm_accept_button": "Delete", "delete_confirm_accept_button": "Delete",
"delete_confirm_cancel_button": "Keep", "delete_confirm_cancel_button": "Keep",
"reply_to": "Reply to", "reply_to": "Reply to",
"reply_to_selected": "Replying to selected message",
"reply_to_last": "Replying to last message",
"reply_to_with_icon": "{icon} {replyTo}", "reply_to_with_icon": "{icon} {replyTo}",
"reply_to_with_arg": "{replyToWithIcon} {user}", "reply_to_with_arg": "{replyToWithIcon} {user}",
"mentions": "Mentions", "mentions": "Mentions",