From c949c3c3fc7efdb7e1b5982bad053cd469ce299d Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 4 Mar 2018 17:16:33 -0800 Subject: [PATCH] Clean up usage of delegate keys --- routes/_actions/statuses.js | 4 ++-- routes/_api/statuses.js | 4 ++-- .../pseudoVirtualList/PseudoVirtualList.html | 5 +++-- routes/_components/status/Status.html | 13 +++++++++---- routes/_components/status/StatusSpoiler.html | 13 +++++++++++-- routes/_components/status/StatusToolbar.html | 7 ++----- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/routes/_actions/statuses.js b/routes/_actions/statuses.js index e7d3188e..e8b84e88 100644 --- a/routes/_actions/statuses.js +++ b/routes/_actions/statuses.js @@ -24,7 +24,7 @@ export async function getNotificationIdsForStatuses (instanceName, statusIds) { return database.getNotificationIdsForStatuses(instanceName, statusIds) } -export async function postStatus(realm, text, inReplyToId, mediaIds, +export async function postStatus (realm, text, inReplyToId, mediaIds, sensitive, spoilerText, visibility) { let instanceName = store.get('currentInstance') let accessToken = store.get('accessToken') @@ -46,4 +46,4 @@ export async function postStatus(realm, text, inReplyToId, mediaIds, } finally { store.set({postingStatus: false}) } -} \ No newline at end of file +} diff --git a/routes/_api/statuses.js b/routes/_api/statuses.js index bea4bb2d..3679dd0c 100644 --- a/routes/_api/statuses.js +++ b/routes/_api/statuses.js @@ -1,7 +1,7 @@ import { auth, basename } from './utils' import { postWithTimeout } from '../_utils/ajax' -export async function postStatus(instanceName, accessToken, text, inReplyToId, mediaIds, +export async function postStatus (instanceName, accessToken, text, inReplyToId, mediaIds, sensitive, spoilerText, visibility) { let url = `${basename(instanceName)}/api/v1/statuses` @@ -22,4 +22,4 @@ export async function postStatus(instanceName, accessToken, text, inReplyToId, m } return postWithTimeout(url, body, auth(accessToken)) -} \ No newline at end of file +} diff --git a/routes/_components/pseudoVirtualList/PseudoVirtualList.html b/routes/_components/pseudoVirtualList/PseudoVirtualList.html index 8cb53ee6..e783e42f 100644 --- a/routes/_components/pseudoVirtualList/PseudoVirtualList.html +++ b/routes/_components/pseudoVirtualList/PseudoVirtualList.html @@ -42,10 +42,11 @@ } this.store.setForRealm({intersectionStates: intersectionStates}) - this.set({intersectionObserver: new IntersectionObserver(this.onIntersection.bind(this), { + let intersectionObserver = new IntersectionObserver(this.onIntersection.bind(this), { root: document.querySelector(this.get('containerQuery')), rootMargin: '300% 0px' - })}) + }) + this.set({intersectionObserver}) this.observe('allItemsHaveHeight', allItemsHaveHeight => { console.log('allItemsHaveHeight', allItemsHaveHeight) if (allItemsHaveHeight && !this.get('initialized')) { diff --git a/routes/_components/status/Status.html b/routes/_components/status/Status.html index 00d0fb2f..34f3394d 100644 --- a/routes/_components/status/Status.html +++ b/routes/_components/status/Status.html @@ -6,7 +6,7 @@ aria-setsize="{{length}}" aria-label="{{ariaLabel}}" on:recalculateHeight> - {{#if (notification && (notification.type === 'reblog' || notification.type === 'favourite')) || status.reblog || timelineType === 'pinned'}} + {{#if showHeader}} {{/if}} @@ -16,7 +16,8 @@ {{/if}} {{#if originalStatus.spoiler_text}} - + {{/if}} {{#if !originalStatus.spoiler_text || spoilerShown}} @@ -97,10 +98,9 @@ export default { oncreate() { let elementKey = this.get('elementKey') - let onClickOrKeydown = this.onClickOrKeydown.bind(this) if (!this.get('isStatusInOwnThread')) { // the whole
is clickable in this case - registerClickDelegate(elementKey, onClickOrKeydown) + registerClickDelegate(elementKey, (e) => this.onClickOrKeydown(e)) } }, ondestroy() { @@ -164,6 +164,11 @@ ariaLabel: (originalAccount, visibility) => { return (visibility === 'direct' ? 'Direct message' : 'Status') + ` by ${originalAccount.display_name || originalAccount.username}` + }, + showHeader: (notification, status, timelineType) => { + return (notification && (notification.type === 'reblog' || notification.type === 'favourite')) + || status.reblog + || timelineType === 'pinned' } } } diff --git a/routes/_components/status/StatusSpoiler.html b/routes/_components/status/StatusSpoiler.html index 6fe6f321..f84a4c1d 100644 --- a/routes/_components/status/StatusSpoiler.html +++ b/routes/_components/status/StatusSpoiler.html @@ -2,7 +2,7 @@

{{status.spoiler_text}}

-
@@ -40,11 +40,20 @@