Skip to content

Commit

Permalink
FET-1573 fix pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
SagiSan committed Aug 13, 2024
1 parent 528bacb commit b8a3946
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions packages/ensjs/src/functions/subgraph/getNamesForAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,59 @@ const getOrderByFilter = ({
>): DomainFilter => {
const lastDomain = previousPage[previousPage.length - 1]
const operator = orderDirection === 'asc' ? 'gt' : 'lt'

switch (orderBy) {
case 'expiryDate': {
console.log(previousPage)
let lastExpiryDate = lastDomain.expiryDate?.value
? lastDomain.expiryDate.value / 1000
: 0
console.log(lastExpiryDate)
if (lastDomain.parentName === 'eth') {
lastExpiryDate += GRACE_PERIOD_SECONDS
}

if (orderDirection === 'asc' && lastExpiryDate === 0) {
console.log('asc 1')
return {
and: [{ expiryDate: null }, { [`id_${operator}`]: lastDomain.id }],
}
}
if (
orderDirection === 'asc' &&
lastExpiryDate !== 0 &&
previousPage.length === 20
) {
console.log('asc 2')
//unwrapped subnames no expiry
//unwrapped .eth names have expiry
//wrapped .eth names have expiry
//wrapped subnames have expiry if fuse else same as unwrapped
//non .eth names no expiry

return {
or: [
{
and: [
{ [`expiryDate_${operator}e`]: `${lastExpiryDate}` },
{ [`id_${operator}`]: lastDomain.id },
],
},
{
[`expiryDate_${operator}`]: `${lastExpiryDate}`,
},
{ expiryDate: null },
],
}
}
if (orderDirection === 'desc' && lastExpiryDate !== 0) {
console.log('desc 1')
return {
[`expiryDate_${operator}`]: `${lastExpiryDate}`,
and: [
{ [`expiryDate_${operator}e`]: `${lastExpiryDate}` },
{ [`id_${operator}`]: lastDomain.id },
],
}
}
console.log('general')
return {
or: [
{
Expand Down Expand Up @@ -195,6 +228,8 @@ const getNamesForAddress = async (
searchType,
...filters
} = filter

console.log('getNames', allowExpired, filters)
const ownerWhereFilters: DomainFilter[] = Object.entries(filters).reduce(
(prev, [key, value]) => {
if (value) {
Expand Down Expand Up @@ -337,6 +372,8 @@ const getNamesForAddress = async (

if (!result) return []

console.log(result.domains)

const names = result.domains.map((domain) => {
const relation: GetNamesForAddressRelation = {}

Expand Down

0 comments on commit b8a3946

Please sign in to comment.