simplify Status.html using spread params (#190)
* simplify Status.html using spread params * fixup
This commit is contained in:
parent
bf36667002
commit
286a93ecba
|
@ -7,40 +7,29 @@
|
||||||
aria-label="{{ariaLabel}}"
|
aria-label="{{ariaLabel}}"
|
||||||
on:recalculateHeight>
|
on:recalculateHeight>
|
||||||
{{#if showHeader}}
|
{{#if showHeader}}
|
||||||
<StatusHeader :notification :notificationId :status :statusId :timelineType
|
<StatusHeader {{...params}} />
|
||||||
:account :accountId :uuid :isStatusInNotification />
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<StatusAuthorName :isStatusInNotification :isStatusInOwnThread :originalAccountId
|
<StatusAuthorName {{...params}} />
|
||||||
:originalAccount :uuid />
|
<StatusAuthorHandle {{...params}} />
|
||||||
<StatusAuthorHandle :isStatusInNotification :originalAccount />
|
|
||||||
{{#if !isStatusInOwnThread}}
|
{{#if !isStatusInOwnThread}}
|
||||||
<StatusRelativeDate :isStatusInNotification :originalStatus :originalStatusId :uuid />
|
<StatusRelativeDate {{...params}} />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<StatusSidebar :isStatusInOwnThread :originalAccount
|
<StatusSidebar {{...params}} />
|
||||||
:originalAccountId :uuid />
|
|
||||||
{{#if spoilerText}}
|
{{#if spoilerText}}
|
||||||
<StatusSpoiler :isStatusInOwnThread :isStatusInNotification
|
<StatusSpoiler {{...params}} on:recalculateHeight />
|
||||||
:originalStatus :uuid :spoilerShown
|
|
||||||
on:recalculateHeight />
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if showContent || contentPreloaded}}
|
{{#if showContent || contentPreloaded}}
|
||||||
<StatusContent :isStatusInOwnThread :isStatusInNotification
|
<StatusContent {{...params}} shown="{{showContent}}"/>
|
||||||
:originalStatus :uuid shown="{{showContent}}"/>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if showMedia }}
|
{{#if showMedia }}
|
||||||
<StatusMediaAttachments :originalStatus :uuid
|
<StatusMediaAttachments {{...params}} on:recalculateHeight />
|
||||||
on:recalculateHeight />
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if isStatusInOwnThread}}
|
{{#if isStatusInOwnThread}}
|
||||||
<StatusDetails :originalStatus :originalStatusId />
|
<StatusDetails {{...params}} />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<StatusToolbar :originalStatus :originalStatusId :originalAccountId
|
<StatusToolbar {{...params}} on:recalculateHeight />
|
||||||
:isStatusInOwnThread :uuid :visibility :replyShown
|
|
||||||
on:recalculateHeight />
|
|
||||||
{{#if replyShown}}
|
{{#if replyShown}}
|
||||||
<StatusComposeBox :originalStatusId :uuid :replyVisibility
|
<StatusComposeBox {{...params}} on:recalculateHeight />
|
||||||
:visibility :spoilerText
|
|
||||||
on:recalculateHeight />
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
@ -180,50 +169,72 @@
|
||||||
originalStatusId: (originalStatus) => originalStatus.id,
|
originalStatusId: (originalStatus) => originalStatus.id,
|
||||||
statusId: (status) => status.id,
|
statusId: (status) => status.id,
|
||||||
notificationId: (notification) => notification && notification.id,
|
notificationId: (notification) => notification && notification.id,
|
||||||
account: (notification, status) => {
|
account: (notification, status) => (
|
||||||
return (notification && notification.account) || status.account
|
(notification && notification.account) || status.account
|
||||||
},
|
),
|
||||||
accountId: (account) => account.id,
|
accountId: (account) => account.id,
|
||||||
originalAccount: (originalStatus) => originalStatus.account,
|
originalAccount: (originalStatus) => originalStatus.account,
|
||||||
originalAccountId: (originalAccount) => originalAccount.id,
|
originalAccountId: (originalAccount) => originalAccount.id,
|
||||||
visibility: (originalStatus) => originalStatus.visibility,
|
visibility: (originalStatus) => originalStatus.visibility,
|
||||||
spoilerText: (originalStatus) => originalStatus.spoiler_text,
|
spoilerText: (originalStatus) => originalStatus.spoiler_text,
|
||||||
uuid: ($currentInstance, timelineType, timelineValue, notificationId, statusId) => {
|
uuid: ($currentInstance, timelineType, timelineValue, notificationId, statusId) => (
|
||||||
return `${$currentInstance}/${timelineType}/${timelineValue}/${notificationId || ''}/${statusId}`
|
`${$currentInstance}/${timelineType}/${timelineValue}/${notificationId || ''}/${statusId}`
|
||||||
},
|
),
|
||||||
delegateKey: (uuid) => `status-${uuid}`,
|
delegateKey: (uuid) => `status-${uuid}`,
|
||||||
isStatusInOwnThread: (timelineType, timelineValue, originalStatusId) => {
|
isStatusInOwnThread: (timelineType, timelineValue, originalStatusId) => (
|
||||||
return (timelineType === 'status' || timelineType === 'reply') && timelineValue === originalStatusId
|
(timelineType === 'status' || timelineType === 'reply') && timelineValue === originalStatusId
|
||||||
},
|
),
|
||||||
isStatusInNotification: (originalStatusId, notification) => {
|
isStatusInNotification: (originalStatusId, notification) => (
|
||||||
return notification && notification.status &&
|
notification && notification.status &&
|
||||||
notification.type !== 'mention' && notification.status.id === originalStatusId
|
notification.type !== 'mention' && notification.status.id === originalStatusId
|
||||||
},
|
),
|
||||||
spoilerShown: ($spoilersShown, uuid) => !!$spoilersShown[uuid],
|
spoilerShown: ($spoilersShown, uuid) => !!$spoilersShown[uuid],
|
||||||
replyShown: ($repliesShown, uuid) => !!$repliesShown[uuid],
|
replyShown: ($repliesShown, uuid) => !!$repliesShown[uuid],
|
||||||
showMedia: (originalStatus, isStatusInNotification) => {
|
showMedia: (originalStatus, isStatusInNotification) => (
|
||||||
return !isStatusInNotification &&
|
!isStatusInNotification &&
|
||||||
originalStatus.media_attachments &&
|
originalStatus.media_attachments &&
|
||||||
originalStatus.media_attachments.length
|
originalStatus.media_attachments.length
|
||||||
},
|
),
|
||||||
ariaLabel: (originalAccount, originalStatus, visibility) => {
|
ariaLabel: (originalAccount, originalStatus, visibility) => (
|
||||||
return (visibility === 'direct' ? 'Direct message' : 'Status') +
|
(visibility === 'direct' ? 'Direct message' : 'Status') +
|
||||||
` by ${originalAccount.display_name || originalAccount.username}`
|
` by ${originalAccount.display_name || originalAccount.username}`
|
||||||
},
|
),
|
||||||
showHeader: (notification, status, timelineType) => {
|
showHeader: (notification, status, timelineType) => (
|
||||||
return (notification && (notification.type === 'reblog' || notification.type === 'favourite')) ||
|
(notification && (notification.type === 'reblog' || notification.type === 'favourite')) ||
|
||||||
status.reblog ||
|
status.reblog ||
|
||||||
timelineType === 'pinned'
|
timelineType === 'pinned'
|
||||||
},
|
),
|
||||||
className: (visibility, timelineType, isStatusInOwnThread) => {
|
className: (visibility, timelineType, isStatusInOwnThread) => (classname(
|
||||||
return classname(
|
|
||||||
'status-article',
|
'status-article',
|
||||||
visibility === 'direct' && 'status-direct',
|
visibility === 'direct' && 'status-direct',
|
||||||
timelineType !== 'search' && 'status-in-timeline',
|
timelineType !== 'search' && 'status-in-timeline',
|
||||||
isStatusInOwnThread && 'status-in-own-thread'
|
isStatusInOwnThread && 'status-in-own-thread'
|
||||||
)
|
)),
|
||||||
},
|
showContent: (spoilerText, spoilerShown) => !spoilerText || spoilerShown,
|
||||||
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
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
Loading…
Reference in a new issue