From b3098c8c5a875cbecc1d5d8d3a6fb4489f49402d Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 13 Apr 2019 11:04:39 -0700 Subject: [PATCH] fix: tweaks to conversations (direct) UI (#1137) - make the url `/direct` - call it "Direct messages" - fix sapper export - retain DM background color - add test --- src/routes/_actions/streaming.js | 2 +- src/routes/_api/TimelineStream.js | 2 +- src/routes/_api/timelines.js | 12 +++++++----- src/routes/_components/NavShortcuts.html | 2 +- src/routes/_components/status/Status.html | 5 +++++ src/routes/_pages/community/index.html | 5 +++-- .../_pages/{conversations.html => direct.html} | 6 +++--- src/routes/_store/computations/navComputations.js | 8 ++++---- src/routes/_store/observers/timelineObservers.js | 2 +- src/routes/{conversations.html => direct.html} | 4 ++-- tests/fixtures.js | 5 +++++ tests/spec/003-basic-timeline-spec.js | 14 +++++++++++++- 12 files changed, 46 insertions(+), 21 deletions(-) rename src/routes/_pages/{conversations.html => direct.html} (82%) rename src/routes/{conversations.html => direct.html} (77%) diff --git a/src/routes/_actions/streaming.js b/src/routes/_actions/streaming.js index 3bd6f297..829dbe2d 100644 --- a/src/routes/_actions/streaming.js +++ b/src/routes/_actions/streaming.js @@ -21,7 +21,7 @@ function processMessage (instanceName, timelineName, message) { // a timeline of statuses. To have a clean implementation we would need to // reproduce what is done for statuses for the conversation. // - // It will add new DMs as new conversations intead of updating existing threads + // It will add new DMs as new conversations instead of updating existing threads addStatusOrNotification(instanceName, timelineName, JSON.parse(payload).last_status) break } diff --git a/src/routes/_api/TimelineStream.js b/src/routes/_api/TimelineStream.js index 1baef004..31501d7b 100644 --- a/src/routes/_api/TimelineStream.js +++ b/src/routes/_api/TimelineStream.js @@ -12,7 +12,7 @@ function getStreamName (timeline) { return 'user' case 'notifications': return 'user:notification' - case 'conversations': + case 'direct': return 'direct' } if (timeline.startsWith('tag/')) { diff --git a/src/routes/_api/timelines.js b/src/routes/_api/timelines.js index 25e9f5c0..bb7f455d 100644 --- a/src/routes/_api/timelines.js +++ b/src/routes/_api/timelines.js @@ -12,7 +12,7 @@ function getTimelineUrlPath (timeline) { return 'notifications' case 'favorites': return 'favourites' - case 'conversations': + case 'direct': return 'conversations' } if (timeline.startsWith('tag/')) { @@ -24,7 +24,7 @@ function getTimelineUrlPath (timeline) { } } -export function getTimeline (instanceName, accessToken, timeline, maxId, since, limit) { +export async function getTimeline (instanceName, accessToken, timeline, maxId, since, limit) { let timelineUrlName = getTimelineUrlPath(timeline) let url = `${basename(instanceName)}/api/v1/${timelineUrlName}` @@ -63,8 +63,10 @@ export function getTimeline (instanceName, accessToken, timeline, maxId, since, url += '?' + paramsString(params) - const timelineRequest = get(url, auth(accessToken), { timeout: DEFAULT_TIMEOUT }) + const items = await get(url, auth(accessToken), { timeout: DEFAULT_TIMEOUT }) - if (timeline !== 'conversations') return timelineRequest - return timelineRequest.then(items => items.map(item => item.last_status)) + if (timeline === 'direct') { + return items.map(item => item.last_status) + } + return items } diff --git a/src/routes/_components/NavShortcuts.html b/src/routes/_components/NavShortcuts.html index edbeb590..00f03a81 100644 --- a/src/routes/_components/NavShortcuts.html +++ b/src/routes/_components/NavShortcuts.html @@ -4,7 +4,7 @@ - + diff --git a/src/routes/_components/status/Status.html b/src/routes/_components/status/Status.html index ef40955a..df3013b1 100644 --- a/src/routes/_components/status/Status.html +++ b/src/routes/_components/status/Status.html @@ -73,6 +73,10 @@ border-bottom: 1px solid var(--main-border); } + .status-article.status-direct { + background-color: var(--status-direct-background); + } + .status-article:focus { outline: none; /* focus is on the parent instead */ } @@ -284,6 +288,7 @@ className: ({ visibility, timelineType, isStatusInOwnThread, $underlineLinks, $disableTapOnStatus }) => (classname( 'status-article', 'shortcut-list-item', + timelineType !== 'direct' && visibility === 'direct' && 'status-direct', timelineType !== 'search' && 'status-in-timeline', isStatusInOwnThread && 'status-in-own-thread', $underlineLinks && 'underline-links', diff --git a/src/routes/_pages/community/index.html b/src/routes/_pages/community/index.html index 565e4bec..4dc7c4ac 100644 --- a/src/routes/_pages/community/index.html +++ b/src/routes/_pages/community/index.html @@ -21,8 +21,8 @@ icon="#fa-star" pinnable="true" /> - @@ -89,6 +89,7 @@ Share Federated Favorites + Conversations {/if}