diff options
author | Accalia <Accalia@Elementia.me> | 2022-05-23 09:19:32 -0400 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2022-05-24 10:49:06 +0200 |
commit | 09e06fd5b001fc5be9ffcb96a6cc97cb545e77a6 (patch) | |
tree | 0a3f221381151f443c8ee15eb820d6193b2d110d | |
parent | f3c824bfaef851a9eec45ef7a3f12588383caf76 (diff) |
update ContentController to fix nextcloud#1324
Signed-off-by: Accalia <Accalia@Elementia.me>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | js/controller/ContentController.js | 16 |
2 files changed, 8 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ea38c643..a48f7a531 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1 ### Fixed - Fix updated api not returning any item after marking item as read (#1713) - Fix deprecation warning for strip_tags() on a null value (#1766) +- Fix selected item being set incorrectly when using default ordering or newest first ordering (#1324) # Releases diff --git a/js/controller/ContentController.js b/js/controller/ContentController.js index ed8d0be55..94098d6c8 100644 --- a/js/controller/ContentController.js +++ b/js/controller/ContentController.js @@ -18,7 +18,7 @@ app.controller('ContentController', function (Publisher, FeedResource, ItemResou // distribute data to models based on key Publisher.publishAll(data); - var getOrdering = function () { + var isOldestFirst = function () { var ordering = SettingsResource.get('oldestFirst'); if (self.isFeed()) { @@ -35,13 +35,11 @@ app.controller('ContentController', function (Publisher, FeedResource, ItemResou this.getFirstItem = function () { var orderedItems = this.getItems(); - var item = orderedItems[orderedItems.length - 1]; - var firstItem = orderedItems[0]; - // If getOrdering == 1, then the sorting is set to - // newest first. So, item should be the first item - // - if (getOrdering()) { - item = firstItem; + var item = orderedItems[0]; + var lastItem = orderedItems[orderedItems.length - 1]; + // If isOldestFirst is set, item should be the last item + if (isOldestFirst()) { + item = lastItem; } if (item === undefined) { return undefined; @@ -152,7 +150,7 @@ app.controller('ContentController', function (Publisher, FeedResource, ItemResou return $route.current.$$route.type === FEED_TYPE.FEED; }; - this.oldestFirst = getOrdering(); + this.oldestFirst = isOldestFirst(); this.autoPage = function () { if (this.isNothingMoreToAutoPage) { |