Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 17 additions & 61 deletions fragments/comments.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import { gql } from '@apollo/client'
import { STREAK_FIELDS } from './common'

// we can't import from users because of circular dependency
const STREAK_FIELDS = gql`
fragment StreakFields on User {
optional {
streak
hasSendWallet
hasRecvWallet
}
}
`

export const COMMENT_FIELDS = gql`
export const COMMENT_FIELDS_NO_CHILD_COMMENTS = gql`
${STREAK_FIELDS}
fragment CommentFields on Item {
fragment CommentFieldsNoChildComments on Item {
id
position
parentId
Expand All @@ -26,16 +16,6 @@ export const COMMENT_FIELDS = gql`
meMute
...StreakFields
}
payIn {
id
payInState
payInType
payInStateChangedAt
payerPrivates {
payInFailureReason
retryCount
}
}
sats
credits
meAnonSats @client
Expand All @@ -54,8 +34,6 @@ export const COMMENT_FIELDS = gql`
commentCredits
mine
otsHash
ncomments
nDirectComments
live @client
imgproxyUrls
rel
Expand All @@ -64,44 +42,22 @@ export const COMMENT_FIELDS = gql`
}
`

export const COMMENT_FIELDS_NO_CHILD_COMMENTS = gql`
${STREAK_FIELDS}
fragment CommentFieldsNoChildComments on Item {
id
position
parentId
createdAt
deletedAt
text
user {
export const COMMENT_FIELDS = gql`
${COMMENT_FIELDS_NO_CHILD_COMMENTS}
fragment CommentFields on Item {
...CommentFieldsNoChildComments
payIn {
id
name
meMute
...StreakFields
payInState
payInType
payInStateChangedAt
payerPrivates {
payInFailureReason
retryCount
}
}
sats
credits
meAnonSats @client
upvotes
freedFreebie
boost
meSats
meCredits
meDontLikeSats
meBookmark
meSubscription
outlawed
freebie
path
commentSats
commentCredits
mine
otsHash
live @client
imgproxyUrls
rel
apiKey
cost
ncomments
nDirectComments
}
`

Expand Down
11 changes: 11 additions & 0 deletions fragments/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { gql } from '@apollo/client'

export const STREAK_FIELDS = gql`
fragment StreakFields on User {
optional {
streak
hasSendWallet
hasRecvWallet
}
}
`
2 changes: 1 addition & 1 deletion fragments/invites.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { gql } from '@apollo/client'
import { STREAK_FIELDS } from './users'
import { STREAK_FIELDS } from './common'

export const INVITE_FIELDS = gql`
${STREAK_FIELDS}
Expand Down
13 changes: 2 additions & 11 deletions fragments/items.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { gql } from '@apollo/client'
import { COMMENTS } from './comments'

// we can't import from users because of circular dependency
const STREAK_FIELDS = gql`
fragment StreakFields on User {
optional {
streak
hasSendWallet
hasRecvWallet
}
}
`
import { STREAK_FIELDS } from './common'

export const ITEM_FIELDS = gql`
${STREAK_FIELDS}
Expand Down Expand Up @@ -128,6 +118,7 @@ export const ITEM_FULL_FIELDS = gql`
}
}`

/** displays timestamp verification infos */
export const ITEM_OTS_FIELDS = gql`
fragment ItemOtsFields on Item {
id
Expand Down
12 changes: 1 addition & 11 deletions fragments/subs.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { gql } from '@apollo/client'
import { ITEM_FIELDS, ITEM_FULL_FIELDS } from './items'
import { COMMENTS_ITEM_EXT_FIELDS } from './comments'

// we can't import from users because of circular dependency
const STREAK_FIELDS = gql`
fragment StreakFields on User {
optional {
streak
hasSendWallet
hasRecvWallet
}
}
`
import { STREAK_FIELDS } from './common'

export const SUB_FIELDS = gql`
fragment SubFields on Sub {
Expand Down
11 changes: 1 addition & 10 deletions fragments/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@ import { gql } from '@apollo/client'
import { COMMENTS, COMMENTS_ITEM_EXT_FIELDS } from './comments'
import { ITEM_FIELDS, ITEM_FULL_FIELDS } from './items'
import { SUB_FULL_FIELDS } from './subs'

export const STREAK_FIELDS = gql`
fragment StreakFields on User {
optional {
streak
hasSendWallet
hasRecvWallet
}
}
`
import { STREAK_FIELDS } from './common'

export const ME = gql`
${STREAK_FIELDS}
Expand Down
9 changes: 5 additions & 4 deletions worker/ots.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import stringifyCanon from 'canonical-json'
import { createHash } from 'crypto'
import Ots from 'opentimestamps'

const ITEM_OTS_FIELDS = gql`
fragment ItemOTSFields on Item {
/** fetches the necessary fields to compute the ots hash */
const ITEM_OTS_HASH_FIELDS = gql`
fragment ItemOtsHashFields on Item {
parentId
parentOtsHash
title
Expand All @@ -15,10 +16,10 @@ const ITEM_OTS_FIELDS = gql`
export async function timestampItem ({ data: { id }, apollo, models }) {
const { data: { item: { parentId, parentOtsHash, title, text, url } } } = await apollo.query({
query: gql`
${ITEM_OTS_FIELDS}
${ITEM_OTS_HASH_FIELDS}
query Item {
item(id: ${id}) {
...ItemOTSFields
...ItemOtsHashFields
}
}`
})
Expand Down