Skip to content

Commit 814d0ee

Browse files
committed
Show pinned posts first everywhere they appear
Fixes Hylozoic/hylo-evo#1416
1 parent 87e5c35 commit 814d0ee

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
## [5.3.4] - 2023-02-14
10+
11+
### Changed
12+
- Pinned posts now appear first in every context they are visible and regardless of the sort
13+
914
## [5.3.3] - 2023-02-09
1015

1116
### Added

api/services/Search/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ export const filterAndSortPosts = curry((opts, q) => {
139139
q.whereRaw('locations.center && ST_MakeEnvelope(?, ?, ?, ?, 4326)', [boundingBox[0].lng, boundingBox[0].lat, boundingBox[1].lng, boundingBox[1].lat])
140140
}
141141

142-
if (sort === 'posts.updated_at' && showPinnedFirst) {
143-
q.orderByRaw('groups_posts.pinned_at is null asc, groups_posts.pinned_at desc, posts.updated_at desc')
142+
if (showPinnedFirst) {
143+
q.orderByRaw(`groups_posts.pinned_at is null asc, groups_posts.pinned_at desc, ${sort || 'posts.updated_at'} ${order || (sortBy === 'order' ? 'asc' : 'desc')}`)
144144
} else if (sort) {
145145
q.orderBy(sort, order || (sortBy === 'order' ? 'asc' : 'desc'))
146146
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Tibet Sprague <tibet@hylo.com>",
66
"license": "GNU AFFERO GENERAL PUBLIC LICENSE v3",
77
"private": true,
8-
"version": "5.3.3",
8+
"version": "5.3.4",
99
"repository": {
1010
"type": "git",
1111
"url": "git://github.com/Hylozoic/hylo-node.git"

0 commit comments

Comments
 (0)