Skip to content

Commit

Permalink
update ContentController to fix #1324
Browse files Browse the repository at this point in the history
Signed-off-by: Accalia <Accalia@Elementia.me>
  • Loading branch information
AccaliaDeElementia authored and Grotax committed May 24, 2022
1 parent f3c824b commit 09e06fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 7 additions & 9 deletions js/controller/ContentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 09e06fd

Please sign in to comment.