default sort by savedAt to avoid recent read page to appear on top of… (#254)

* default sort by savedAt to avoid recent read page to appear on top of the list

* revert lint on generated code
This commit is contained in:
Hongbo Wu
2022-03-17 10:54:00 +08:00
committed by GitHub
parent af037a2837
commit a2ce98229e
5 changed files with 9 additions and 4 deletions

View File

@ -393,7 +393,8 @@ export const searchPages = async (
inFilter,
} = args
const sortOrder = sort?.order === SortOrder.Ascending ? 'asc' : 'desc'
const sortField = sort?.by === SortBy.Score ? '_score' : 'updatedAt'
// default sort by saved_at
const sortField = sort?.by === SortBy.Score ? '_score' : 'savedAt'
const includeLabels = labelFilters.filter(
(filter) => filter.type === LabelFilterType.INCLUDE
)

View File

@ -1512,6 +1512,7 @@ export type SignupSuccess = {
};
export enum SortBy {
SavedAt = 'SAVED_AT',
Score = 'SCORE',
UpdatedTime = 'UPDATED_TIME'
}

View File

@ -1133,6 +1133,7 @@ type SignupSuccess {
}
enum SortBy {
SAVED_AT
SCORE
UPDATED_TIME
}

View File

@ -27,6 +27,7 @@ const schema = gql`
enum SortBy {
UPDATED_TIME
SCORE
SAVED_AT
}
enum ContentReader {

View File

@ -123,15 +123,16 @@ const parseSortParams = (str?: string): SortParams | undefined => {
order?.toUpperCase() === 'ASC' ? SortOrder.Ascending : SortOrder.Descending
switch (sort.toUpperCase()) {
case 'UPDATED_AT':
case 'UPDATED_TIME':
case 'SAVED_AT':
return {
by: SortBy.UpdatedTime,
by: SortBy.SavedAt,
order: sortOrder,
}
case 'SCORE':
// sort by score does not need an order
return {
by: SortBy.Score,
order: sortOrder,
}
}
}