Pinafore-Web-Client-Frontend/src/routes/_components/status/StatusToolbar.html

236 lines
7.6 KiB
HTML
Raw Normal View History

<div class="status-toolbar {isStatusInOwnThread ? 'status-in-own-thread' : ''}" ref:node>
2018-01-28 21:51:48 +01:00
<IconButton
className="status-toolbar-reply-button"
label={replyLabel}
pressedLabel="{intl.closeReply}"
pressable={true}
pressed={replyShown}
2018-06-14 17:42:55 +02:00
href={replyIcon}
clickListener={false}
elementId={replyKey}
2018-01-28 21:51:48 +01:00
/>
<IconButton
label={reblogLabel}
pressedLabel="Unboost"
pressable={!reblogDisabled}
pressed={reblogged}
checked={reblogged}
disabled={reblogDisabled}
href={reblogIcon}
clickListener={false}
elementId={reblogKey}
2018-04-21 17:32:40 +02:00
ref:reblogIcon
2018-01-28 21:51:48 +01:00
/>
<IconButton
label="{intl.favorite}"
pressedLabel="{intl.unfavorite}"
pressable={true}
pressed={favorited}
checked={favorited}
2018-01-28 21:51:48 +01:00
href="#fa-star"
clickListener={false}
elementId={favoriteKey}
2018-04-21 17:32:40 +02:00
ref:favoriteIcon
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
/>
2018-01-28 21:51:48 +01:00
<IconButton
label="{intl.moreOptions}"
2018-01-28 21:51:48 +01:00
href="#fa-ellipsis-h"
clickListener={false}
elementId={optionsKey}
2018-01-28 21:51:48 +01:00
/>
</div>
{#if enableShortcuts}
<Shortcut scope={shortcutScope} key="f" on:pressed="toggleFavorite(true)"/>
<Shortcut scope={shortcutScope} key="r" on:pressed="reply()"/>
<Shortcut scope={shortcutScope} key="escape" on:pressed="dismiss()"/>
<Shortcut scope={shortcutScope} key="b" on:pressed="reblog(true)"/>
<Shortcut scope={shortcutScope} key="a" on:pressed="bookmark()"/>
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
{/if}
<style>
.status-toolbar {
2018-02-10 05:07:48 +01:00
grid-area: toolbar;
display: flex;
justify-content: space-between;
pointer-events: none;
}
.status-toolbar.status-in-own-thread {
2018-05-14 03:53:37 +02:00
margin-left: 63px; /* offset to align all toolbar items: 48px avatar + 15px margin-right */
}
2018-05-14 03:53:37 +02:00
@media (max-width: 767px) {
.status-toolbar.status-in-own-thread {
margin-left: 53px; /* offset to align all toolbar items: 48px avatar + 5px margin-right */
}
}
@media (max-width: 240px) {
:global(.status-toolbar .icon-button-svg) {
width: 20px;
height: 20px;
}
}
</style>
<script>
2018-01-28 21:51:48 +01:00
import IconButton from '../IconButton.html'
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
import Shortcut from '../shortcut/Shortcut.html'
import { store } from '../../_store/store.js'
import { registerClickDelegates } from '../../_utils/delegate.js'
import { setFavorited } from '../../_actions/favorite.js'
import { setReblogged } from '../../_actions/reblog.js'
import { importShowStatusOptionsDialog } from '../dialog/asyncDialogs/importShowStatusOptionsDialog.js'
import { updateProfileAndRelationship } from '../../_actions/accounts.js'
import { CHECKMARK_ANIMATION, FAVORITE_ANIMATION, REBLOG_ANIMATION } from '../../_static/animations.js'
import { on } from '../../_utils/eventBus.js'
import { announceAriaLivePolite } from '../../_utils/announceAriaLivePolite.js'
import { setStatusBookmarkedOrUnbookmarked } from '../../_actions/bookmark.js'
2018-01-28 21:51:48 +01:00
export default {
2018-04-20 06:38:01 +02:00
oncreate () {
2019-08-03 22:49:37 +02:00
const {
favoriteKey,
reblogKey,
replyKey,
optionsKey
} = this.get()
registerClickDelegates(this, {
[favoriteKey]: () => {
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
this.toggleFavorite()
return true
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
},
[reblogKey]: () => {
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
this.reblog()
return true
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
},
[replyKey]: () => {
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
this.reply()
return true
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
},
[optionsKey]: () => {
this.onOptionsClick()
return true
}
})
on('postedStatus', this, this.onPostedStatus)
2018-02-24 23:49:28 +01:00
},
2018-01-28 21:51:48 +01:00
components: {
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
IconButton,
Shortcut
2018-02-19 19:34:36 +01:00
},
2018-02-24 03:23:36 +01:00
store: () => store,
2018-02-24 23:49:28 +01:00
methods: {
toggleFavorite (announce) {
2019-08-03 22:49:37 +02:00
const { originalStatusId, favorited } = this.get()
const newFavoritedValue = !favorited
2018-04-21 17:32:40 +02:00
/* no await */ setFavorited(originalStatusId, newFavoritedValue)
if (newFavoritedValue) {
this.refs.favoriteIcon.animate(FAVORITE_ANIMATION, CHECKMARK_ANIMATION)
2018-04-21 17:32:40 +02:00
}
if (announce) {
announceAriaLivePolite(newFavoritedValue ? 'intl.favorited' : 'intl.unfavorited')
}
2018-02-25 03:20:33 +01:00
},
reblog (announce) {
2019-08-03 22:49:37 +02:00
const { originalStatusId, reblogged } = this.get()
const newRebloggedValue = !reblogged
2018-04-21 17:32:40 +02:00
/* no await */ setReblogged(originalStatusId, newRebloggedValue)
if (newRebloggedValue) {
this.refs.reblogIcon.animate(REBLOG_ANIMATION, CHECKMARK_ANIMATION)
2018-04-21 17:32:40 +02:00
}
if (announce) {
announceAriaLivePolite(newRebloggedValue ? 'intl.reblogged' : 'intl.unreblogged')
}
2018-03-08 03:04:20 +01:00
},
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
reply () {
2018-03-30 10:06:17 +02:00
requestAnimationFrame(() => {
2019-08-03 22:49:37 +02:00
const { uuid } = this.get()
const { repliesShown } = this.store.get()
repliesShown[uuid] = !repliesShown[uuid]
this.store.set({ repliesShown })
2018-03-30 10:06:17 +02:00
this.fire('recalculateHeight')
})
2018-03-12 03:40:32 +01:00
},
dismiss () {
const { replyShown } = this.get()
if (replyShown) {
this.reply()
this.fire('focusArticle')
}
},
async onOptionsClick () {
2019-08-03 22:49:37 +02:00
const { originalStatus, originalAccountId } = this.get()
const updateRelationshipPromise = updateProfileAndRelationship(originalAccountId)
const showStatusOptionsDialog = await importShowStatusOptionsDialog()
2018-03-12 03:40:32 +01:00
await updateRelationshipPromise
showStatusOptionsDialog(originalStatus)
},
2018-04-20 06:38:01 +02:00
onPostedStatus (realm, inReplyToUuid) {
2019-08-03 22:49:37 +02:00
const {
originalStatusId,
uuid
} = this.get()
if (realm !== originalStatusId ||
inReplyToUuid !== uuid) {
return
}
try {
// return status to the reply button after posting a reply
this.refs.node.querySelector('.status-toolbar-reply-button').focus({ preventScroll: true })
} catch (e) { /* ignore */ }
},
bookmark () {
const { originalStatus, originalStatusId } = this.get()
/* no await */ setStatusBookmarkedOrUnbookmarked(originalStatusId, !originalStatus.bookmarked)
2018-02-24 23:49:28 +01:00
}
},
2018-03-21 17:38:20 +01:00
data: () => ({
favoriteAnimation: FAVORITE_ANIMATION,
reblogAnimation: REBLOG_ANIMATION
}),
2018-02-19 19:34:36 +01:00
computed: {
replyLabel: ({ inReplyToId }) => (
inReplyToId ? 'intl.replyToThread' : 'intl.reply'
2018-06-14 17:42:55 +02:00
),
replyIcon: ({ inReplyToId }) => inReplyToId ? '#fa-reply-all' : '#fa-reply',
reblogLabel: ({ visibility }) => {
2018-02-19 19:34:36 +01:00
switch (visibility) {
case 'private':
return 'intl.cannotReblogFollowersOnly'
2018-02-19 19:34:36 +01:00
case 'direct':
return 'intl.cannotReblogDirectMessage'
2018-02-19 19:34:36 +01:00
default:
return 'intl.reblog'
2018-02-19 19:34:36 +01:00
}
},
reblogIcon: ({ visibility }) => {
2018-02-19 19:34:36 +01:00
switch (visibility) {
case 'private':
return '#fa-lock'
case 'direct':
return '#fa-envelope'
default:
return '#fa-retweet'
}
},
reblogDisabled: ({ visibility }) => {
2018-02-19 19:34:36 +01:00
return visibility === 'private' || visibility === 'direct'
2018-02-24 03:23:36 +01:00
},
reblogged: ({ originalStatusId, $currentStatusModifications, originalStatus }) => {
if ($currentStatusModifications && originalStatusId in $currentStatusModifications.reblogs) {
return $currentStatusModifications.reblogs[originalStatusId]
2018-02-25 03:20:33 +01:00
}
return originalStatus.reblogged
2018-02-25 03:20:33 +01:00
},
favorited: ({ originalStatusId, $currentStatusModifications, originalStatus }) => {
if ($currentStatusModifications && originalStatusId in $currentStatusModifications.favorites) {
return $currentStatusModifications.favorites[originalStatusId]
2018-02-24 03:23:36 +01:00
}
return originalStatus.favourited
2018-02-24 23:49:28 +01:00
},
favoriteKey: ({ uuid }) => `fav-${uuid}`,
reblogKey: ({ uuid }) => `reblog-${uuid}`,
replyKey: ({ uuid }) => `reply-${uuid}`,
optionsKey: ({ uuid }) => `options-${uuid}`
2018-01-28 21:51:48 +01:00
}
}
feat: Add support for keyboard shortcuts (#870) * Add support for keyboard shortcuts. This change introduces a Shortcut component for defining global keyboard shortcuts from whichever component makes more sense. This change also adds an initial set of navigation shortcuts: - Backspace to leave a modal dialog or to go back - g t to go to the federated timeline - g f to go to the favorite page - g h to go to the home page - g n to go to the notification page - g c to go to the community page - s to go to the search page These shortcuts are loaded asynchronously from _layout.html In modal dialogs, shortcuts are also modal, to avoid strange or overly complex behavior. This is implemented by grouping shortcuts into scopes, and activating a separate 'modal' scope when entering a modal dialog, so a separate set of shortcuts can be enabled in modal dialog. Modal dialogs can be exited by pressing 'Backspace'. * Navigate up/down lists using keyboard shortcuts. This change introduces keyboard shortcuts for navigating in lists and virtual lists. j or arrow up selects the next element, k or arrow down, the previous element. Selecting an element scrolls the list up and down, as necessary. This change also allows directing keyboard shortcuts to the active element and defines the following shortcuts, for the active status: - f to favorite or unfavorite it - b to boost or unboost it - r to reply to it - o to open its thread - x to toggle the display of a CW - y to toggle the display of sensitive medias This works by defining a keyboard shortcut scope for each list element. A new component, ScrollListShortcuts, keeps track of the active element, based on list or virtual list elements and redirects shortcuts to the active element's scope. ScrollListShortcuts keeps the active element in the current realm of the store, so the active element is restored when going back to the list. * Typing h or ? displays the list of available keyboard shortcuts. This change introduces a new modal dialog that documents the list of available shortcuts.
2019-01-13 19:03:29 +01:00
</script>