From 286a93ecbae37cced1f1cab1b570e6286a74b400 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 21 Apr 2018 00:33:30 -0700 Subject: [PATCH] simplify Status.html using spread params (#190) * simplify Status.html using spread params * fixup --- routes/_components/status/Status.html | 115 ++++++++++++++------------ 1 file changed, 63 insertions(+), 52 deletions(-) diff --git a/routes/_components/status/Status.html b/routes/_components/status/Status.html index f3f6e085..fdfde448 100644 --- a/routes/_components/status/Status.html +++ b/routes/_components/status/Status.html @@ -7,40 +7,29 @@ aria-label="{{ariaLabel}}" on:recalculateHeight> {{#if showHeader}} - + {{/if}} - - + + {{#if !isStatusInOwnThread}} - + {{/if}} - + {{#if spoilerText}} - + {{/if}} {{#if showContent || contentPreloaded}} - + {{/if}} {{#if showMedia }} - + {{/if}} {{#if isStatusInOwnThread}} - + {{/if}} - + {{#if replyShown}} - + {{/if}} @@ -180,50 +169,72 @@ originalStatusId: (originalStatus) => originalStatus.id, statusId: (status) => status.id, notificationId: (notification) => notification && notification.id, - account: (notification, status) => { - return (notification && notification.account) || status.account - }, + account: (notification, status) => ( + (notification && notification.account) || status.account + ), accountId: (account) => account.id, originalAccount: (originalStatus) => originalStatus.account, originalAccountId: (originalAccount) => originalAccount.id, visibility: (originalStatus) => originalStatus.visibility, spoilerText: (originalStatus) => originalStatus.spoiler_text, - uuid: ($currentInstance, timelineType, timelineValue, notificationId, statusId) => { - return `${$currentInstance}/${timelineType}/${timelineValue}/${notificationId || ''}/${statusId}` - }, + uuid: ($currentInstance, timelineType, timelineValue, notificationId, statusId) => ( + `${$currentInstance}/${timelineType}/${timelineValue}/${notificationId || ''}/${statusId}` + ), delegateKey: (uuid) => `status-${uuid}`, - isStatusInOwnThread: (timelineType, timelineValue, originalStatusId) => { - return (timelineType === 'status' || timelineType === 'reply') && timelineValue === originalStatusId - }, - isStatusInNotification: (originalStatusId, notification) => { - return notification && notification.status && + isStatusInOwnThread: (timelineType, timelineValue, originalStatusId) => ( + (timelineType === 'status' || timelineType === 'reply') && timelineValue === originalStatusId + ), + isStatusInNotification: (originalStatusId, notification) => ( + notification && notification.status && notification.type !== 'mention' && notification.status.id === originalStatusId - }, + ), spoilerShown: ($spoilersShown, uuid) => !!$spoilersShown[uuid], replyShown: ($repliesShown, uuid) => !!$repliesShown[uuid], - showMedia: (originalStatus, isStatusInNotification) => { - return !isStatusInNotification && + showMedia: (originalStatus, isStatusInNotification) => ( + !isStatusInNotification && originalStatus.media_attachments && originalStatus.media_attachments.length - }, - ariaLabel: (originalAccount, originalStatus, visibility) => { - return (visibility === 'direct' ? 'Direct message' : 'Status') + + ), + ariaLabel: (originalAccount, originalStatus, visibility) => ( + (visibility === 'direct' ? 'Direct message' : 'Status') + ` by ${originalAccount.display_name || originalAccount.username}` - }, - showHeader: (notification, status, timelineType) => { - return (notification && (notification.type === 'reblog' || notification.type === 'favourite')) || + ), + showHeader: (notification, status, timelineType) => ( + (notification && (notification.type === 'reblog' || notification.type === 'favourite')) || status.reblog || timelineType === 'pinned' - }, - className: (visibility, timelineType, isStatusInOwnThread) => { - return classname( - 'status-article', - visibility === 'direct' && 'status-direct', - timelineType !== 'search' && 'status-in-timeline', - isStatusInOwnThread && 'status-in-own-thread' - ) - }, - showContent: (spoilerText, spoilerShown) => !spoilerText || spoilerShown + ), + className: (visibility, timelineType, isStatusInOwnThread) => (classname( + 'status-article', + visibility === 'direct' && 'status-direct', + timelineType !== 'search' && 'status-in-timeline', + isStatusInOwnThread && 'status-in-own-thread' + )), + showContent: (spoilerText, spoilerShown) => !spoilerText || spoilerShown, + params: (notification, notificationId, status, statusId, timelineType, + account, accountId, uuid, isStatusInNotification, isStatusInOwnThread, + originalAccount, originalAccountId, spoilerShown, visibility, replyShown, + replyVisibility, spoilerText, originalStatus, originalStatusId) => ({ + notification, + notificationId, + status, + statusId, + timelineType, + account, + accountId, + uuid, + isStatusInNotification, + isStatusInOwnThread, + originalAccount, + originalAccountId, + spoilerShown, + visibility, + replyShown, + replyVisibility, + spoilerText, + originalStatus, + originalStatusId + }) } } \ No newline at end of file