Skip to content

Commit e96b5a0

Browse files
author
crzypatchwork
committed
latest
1 parent ed38051 commit e96b5a0

File tree

2 files changed

+88
-37
lines changed

2 files changed

+88
-37
lines changed

src/pages/feeds/feeds.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ const customFloor = function (value, roundTo) {
2020
return Math.floor(value / roundTo) * roundTo
2121
}
2222

23-
/* const GetUserClaims = async (arr) => {
24-
console.log(JSON.stringify(arr))
25-
return await axios.post('https://indexer.tzprofiles.com/v1/graphql', {
26-
query: `query MyQuery {
27-
tzprofiles(where: {account: {_in: ${JSON.stringify(arr)}}}) {
28-
account
29-
valid_claims
30-
}
31-
}`,
32-
variables: undefined,
33-
operationName: 'MyQuery',
34-
})
35-
} */
23+
const tz_profiles = `
24+
query profiles {
25+
tzprofiles(where: {account: {_in: $arr }}) {
26+
account
27+
contract
28+
}
29+
}
30+
`
3631

3732
const latest_feed = `
3833
query LatestFeed($lastId: bigint = 99999999) {
@@ -71,9 +66,7 @@ const query_hdao = `query hDAOFeed($offset: Int = 0) {
7166
}`
7267

7368
async function fetchProfiles(arr) {
74-
const { errors, data } = await fetchGraphQLProfiles(
75-
tzprofiles, "MyQuery", {})
76-
console.log(data)
69+
const { errors, data } = await fetchGraphQLProfiles(tz_profiles, "profiles", { "arr": arr })
7770
return data.tzprofiles
7871
}
7972

@@ -184,10 +177,18 @@ async function fetchRandomObjkts() {
184177
const getRestrictedAddresses = async () =>
185178
await axios
186179
.get(
187-
'https://raw.githubusercontent.com/hicetnunc2000/hicetnunc-reports/main/filters/w.json'
180+
'https://raw.githubusercontent.com/hicetnunc2000/hicetnunc/main/filters/w.json'
188181
)
189182
.then((res) => res.data)
190183

184+
const GetUserClaims = async (arr) => {
185+
return await axios.post('https://indexer.tzprofiles.com/v1/graphql', {
186+
query: `query MyQuery { tzprofiles_by_pk(account: \"${walletAddr}\") { valid_claims } }`,
187+
variables: null,
188+
operationName: 'MyQuery',
189+
})
190+
}
191+
191192
const ONE_MINUTE_MILLIS = 60 * 1000
192193

193194
export const Feeds = ({ type }) => {
@@ -201,11 +202,11 @@ export const Feeds = ({ type }) => {
201202
const startTime = customFloor(Date.now(), ONE_MINUTE_MILLIS)
202203

203204
const loadMore = async () => {
204-
if (type === 1) {
205+
/* if (type === 1) {
205206
await getHdaoFeed()
206-
}
207-
if (type === 2) await getRandomFeed()
208-
if (type === 3) await getLatest(Math.min.apply(Math, items.map(e => e.id)))
207+
} */
208+
await getRandomFeed()
209+
//if (type === 3) await getLatest(Math.min.apply(Math, items.map(e => e.id)))
209210
}
210211

211212
useEffect(async () => {
@@ -214,7 +215,7 @@ export const Feeds = ({ type }) => {
214215
return
215216
}
216217
console.log(type)
217-
if (type === 0) {
218+
/* if (type === 0) {
218219
GetLatestFeed({ counter: count, max_time: startTime })
219220
.then((result) => {
220221
const next = items.concat(result)
@@ -230,10 +231,10 @@ export const Feeds = ({ type }) => {
230231
})
231232
} else if (type === 1) {
232233
await getHdaoFeed()
233-
} else if (type === 2) {
234+
} else if (type === 2) { */
234235
await getRandomFeed()
235-
} else if (type === 3) {
236-
await getLatest(lastId)
236+
/* } else if (type === 3) {
237+
await getLatest(lastId) */
237238

238239
/* GetFeaturedFeed({ counter: count, max_time: startTime })
239240
.then((result) => {
@@ -249,7 +250,7 @@ export const Feeds = ({ type }) => {
249250
.catch((e) => {
250251
setError(true)
251252
}) */
252-
}
253+
//}
253254
}, [count, type])
254255

255256
const getLatest = async (id) => {
@@ -261,8 +262,7 @@ export const Feeds = ({ type }) => {
261262
result = _.uniqBy(result, 'creator_id')
262263
setCreators(creators.concat(result.map(e => e.creator_id)))
263264
result = result.filter(e => !creators.includes(e.creator_id))
264-
let arr = result.map(e => e.creator_id)
265-
//console.log(await GetUserClaims(arr))
265+
266266
let restricted = await getRestrictedAddresses()
267267
result = result.filter(e => !restricted.includes(e.creator_id))
268268
const next = items.concat(result)
@@ -322,7 +322,7 @@ export const Feeds = ({ type }) => {
322322
</Padding>
323323
</Container>
324324
}
325-
{/* <BottomBanner>
325+
{/* <BottomBanner>
326326
API is down due to heavy server load — We're working to fix the issue — please be patient with us. <a href="https://discord.gg/mNNSpxpDce" target="_blank">Join the discord</a> for updates.
327327
</BottomBanner> */}
328328
</Page>

src/pages/search/index.js

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Input } from '../../components/input'
99
import InfiniteScroll from 'react-infinite-scroll-component'
1010
import { renderMediaType } from '../../components/media-types'
1111
import './style.css'
12+
import { last } from 'lodash'
1213

1314
const axios = require('axios')
1415
const ls = require('local-storage')
@@ -174,7 +175,7 @@ async function fetchGLB(offset) {
174175
async function fetchInteractive(offset) {
175176
const { errors, data } = await fetchGraphQL(`
176177
query InteractiveObjkts {
177-
hic_et_nunc_token(where: { mime: {_in : [ "application/x-directory" ]}, supply : { _neq : 0 } }, limit : 15, offset : ${offset}, order_by: {id: desc}) {
178+
hic_et_nunc_token(where: { mime: {_in : [ "application/x-directory", "image/svg+xml" ]}, supply : { _neq : 0 } }, limit : 15, offset : ${offset}, order_by: {id: desc}) {
178179
id
179180
artifact_uri
180181
display_uri
@@ -341,6 +342,7 @@ async function fetchRandomObjkts() {
341342
}
342343

343344
async function fetchDay(day, offset) {
345+
console.log(day)
344346
const { errors, data } = await fetchGraphQL(`query dayTrades {
345347
hic_et_nunc_trade(where: {timestamp: {_gte: "${day}"}}, order_by: {swap: {price: desc}}, limit : 15, offset : ${offset}) {
346348
timestamp
@@ -370,6 +372,38 @@ async function fetchDay(day, offset) {
370372

371373
}
372374

375+
async function fetchSales(offset) {
376+
console.log(offset)
377+
const { errors, data } = await fetchGraphQL(`
378+
query sales {
379+
hic_et_nunc_trade(order_by: {timestamp: desc}, limit : 15, offset : ${offset}) {
380+
timestamp
381+
swap {
382+
price
383+
}
384+
token {
385+
artifact_uri
386+
display_uri
387+
id
388+
mime
389+
}
390+
}
391+
}`, 'sales', {})
392+
393+
if (errors) {
394+
console.log(errors)
395+
}
396+
397+
let result = []
398+
399+
try {
400+
result = data.hic_et_nunc_trade
401+
} catch (e) { }
402+
403+
return result
404+
405+
}
406+
373407
async function fetchSubjkts(subjkt) {
374408
//console.log(subjkt)
375409
const { errors, data } = await fetchGraphQL(`
@@ -464,6 +498,8 @@ async function fetchHdao(offset) {
464498
return result
465499
}
466500

501+
502+
467503
export class Search extends Component {
468504
static contextType = HicetnuncContext
469505

@@ -476,15 +512,17 @@ export class Search extends Component {
476512
prev: '',
477513
reset: false,
478514
flag: false,
515+
lastId: undefined,
479516
tags: [
480517
{ id: 0, value: '○' },
481-
{ id: 1, value: 'random' },
482-
{ id: 2, value: 'glb' },
483-
{ id: 3, value: 'music' },
484-
{ id: 4, value: 'interactive' },
485-
{ id: 5, value: 'gif' },
486-
{ id: 6, value: '1D'},
487-
{ id: 7, value: '1W'},
518+
{ id: 1, value: 'latest sales' },
519+
{ id: 2, value: 'latest mints' },
520+
{ id: 3, value: 'glb' },
521+
{ id: 4, value: 'music' },
522+
{ id: 5, value: 'interactive' },
523+
{ id: 6, value: 'gif' },
524+
{ id: 7, value: '1D'},
525+
{ id: 8, value: '1W'}
488526
/* { id: 4, value: 'illustration' }, */
489527
/* { id: 5, value: 'gif' } */
490528

@@ -588,6 +626,19 @@ export class Search extends Component {
588626
this.setState({ feed: [...this.state.feed, ...(await fetchTag(this.state.search, this.state.feed[this.state.feed.length - 1].id))] })
589627
}
590628

629+
if (e == 'latest sales') {
630+
let tokens = await fetchSales(this.state.offset + 250)
631+
tokens = tokens.map(e => e.token)
632+
tokens = _.uniqBy(tokens, 'id')
633+
634+
this.setState({ feed: _.uniqBy([...this.state.feed, ...tokens], 'id')})
635+
}
636+
637+
if (e == 'latest mints') {
638+
this.setState({ feed: [...this.state.feed, ...(await fetchFeed(999999 || this.state.lastId))] })
639+
this.setState({ lastId : Math.min.apply(Math, this.state.feed.map(e => e.id))})
640+
}
641+
591642
this.setState({ reset: false })
592643

593644
//this.setState({ feed : this.state.feed })

0 commit comments

Comments
 (0)