From 2efcb16bcc7535af2e735a342a880957cd20fa68 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 10 Feb 2018 12:34:54 -0800 Subject: [PATCH] more work on trying to get focus saving to work --- routes/_components/status/Status.html | 1 + .../_components/status/StatusAuthorName.html | 25 ++++--------------- routes/_components/status/StatusHeader.html | 8 +++++- .../status/StatusRelativeDate.html | 8 ++++-- routes/_components/timeline/Timeline.html | 9 ++++--- routes/_store/mixins.js | 6 +++++ routes/_store/timelineComputations.js | 1 + 7 files changed, 32 insertions(+), 26 deletions(-) diff --git a/routes/_components/status/Status.html b/routes/_components/status/Status.html index 7996f06b..11fd2474 100644 --- a/routes/_components/status/Status.html +++ b/routes/_components/status/Status.html @@ -141,6 +141,7 @@ parentElement.parentElement.localName !== 'button') { e.preventDefault() e.stopPropagation() + this.store.setForCurrentTimeline({ignoreBlurEvents: true}) goto(`/statuses/${this.get('statusId')}`) } } diff --git a/routes/_components/status/StatusAuthorName.html b/routes/_components/status/StatusAuthorName.html index b9dd738a..35033eb9 100644 --- a/routes/_components/status/StatusAuthorName.html +++ b/routes/_components/status/StatusAuthorName.html @@ -1,5 +1,7 @@ + href="/accounts/{{status.account.id}}" + focus-key="{{focusKey}}" +> {{status.account.display_name || status.account.username}} \ No newline at end of file diff --git a/routes/_components/status/StatusHeader.html b/routes/_components/status/StatusHeader.html index 5c36ba4c..8836d6d9 100644 --- a/routes/_components/status/StatusHeader.html +++ b/routes/_components/status/StatusHeader.html @@ -3,7 +3,9 @@ - + {{getAccount(notification, status).display_name || ('@' + getAccount(notification, status).username)}} {{#if notification && notification.type === 'reblog'}} @@ -62,6 +64,10 @@ \ No newline at end of file diff --git a/routes/_components/timeline/Timeline.html b/routes/_components/timeline/Timeline.html index 62f98498..1c4f6cd3 100644 --- a/routes/_components/timeline/Timeline.html +++ b/routes/_components/timeline/Timeline.html @@ -65,9 +65,9 @@ export default { oncreate() { console.log('timeline oncreate()') + this.store.setForCurrentTimeline({ignoreBlurEvents: false}) setupTimeline() if (this.store.get('initialized')) { - console.log('initialized!!!!') this.restoreFocus() } }, @@ -159,12 +159,15 @@ }) }, clearFocus() { - /*console.log('clearing focus') + if (this.store.get('ignoreBlurEvents')) { + return + } + console.log('clearing focus') let instanceName = this.store.get('currentInstance') let timelineName = this.get('timeline') this.store.setForTimeline(instanceName, timelineName, { lastFocusedElementSelector: null - })*/ + }) }, restoreFocus() { let lastFocusedElementSelector = this.store.get('lastFocusedElementSelector') diff --git a/routes/_store/mixins.js b/routes/_store/mixins.js index efd7490b..1a247c14 100644 --- a/routes/_store/mixins.js +++ b/routes/_store/mixins.js @@ -12,6 +12,12 @@ function timelineMixins (Store) { let timelineData = timelines[instanceName] || {} return (timelineData[timelineName] || {})[key] } + + Store.prototype.setForCurrentTimeline = function (obj) { + let instanceName = this.get('currentInstance') + let timelineName = this.get('currentTimeline') + this.setForTimeline(instanceName, timelineName, obj) + } } export function mixins (Store) { diff --git a/routes/_store/timelineComputations.js b/routes/_store/timelineComputations.js index dbff7cfe..dd332fb8 100644 --- a/routes/_store/timelineComputations.js +++ b/routes/_store/timelineComputations.js @@ -14,6 +14,7 @@ export function timelineComputations (store) { computeForTimeline(store, 'runningUpdate') computeForTimeline(store, 'initialized') computeForTimeline(store, 'lastFocusedElementSelector') + computeForTimeline(store, 'ignoreBlurEvents') store.compute('lastTimelineItemId', ['timelineItemIds'], (timelineItemIds) => timelineItemIds && timelineItemIds.length && timelineItemIds[timelineItemIds.length - 1]) }