diff --git a/api/typeDefs/user.js b/api/typeDefs/user.js index 1fe2bdf0..e79a4722 100644 --- a/api/typeDefs/user.js +++ b/api/typeDefs/user.js @@ -19,8 +19,8 @@ export default gql` extend type Mutation { setName(name: String!): Boolean - setSettings(tipDefault: Int!, fiatCurrency: String!, noteItemSats: Boolean!, noteEarning: Boolean!, - noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!, + setSettings(tipDefault: Int!, turboTipping: Boolean!, fiatCurrency: String!, noteItemSats: Boolean!, + noteEarning: Boolean!, noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!, noteInvites: Boolean!, noteJobIndicator: Boolean!, hideInvoiceDesc: Boolean!, hideFromTopUsers: Boolean!, wildWestMode: Boolean!, greeterMode: Boolean!): User setPhoto(photoId: ID!): Int! @@ -49,6 +49,7 @@ export default gql` freeComments: Int! hasInvites: Boolean! tipDefault: Int! + turboTipping: Boolean! fiatCurrency: String! bio: Item bioId: Int diff --git a/components/upvote.js b/components/upvote.js index f1c44404..f2ef5190 100644 --- a/components/upvote.js +++ b/components/upvote.js @@ -152,11 +152,19 @@ export default function UpVote ({ item, className }) { } ) - const overlayText = () => { - if (me?.tipDefault) { - return `${me.tipDefault} sat${me.tipDefault > 1 ? 's' : ''}` + // what should our next tip be? + let sats = me?.tipDefault || 1 + if (me?.turboTipping && item?.meSats) { + let raiseTip = sats + while (item?.meSats >= raiseTip) { + raiseTip *= 10 } - return '1 sat' + + sats = raiseTip - item.meSats + } + + const overlayText = () => { + return `${sats} sat${sats > 1 ? 's' : ''}` } const color = getColor(item?.meSats) @@ -196,11 +204,11 @@ export default function UpVote ({ item, className }) { try { await act({ - variables: { id: item.id, sats: me.tipDefault || 1 }, + variables: { id: item.id, sats }, optimisticResponse: { act: { id: `Item:${item.id}`, - sats: me.tipDefault || 1, + sats, vote: 0 } } diff --git a/fragments/users.js b/fragments/users.js index 8fed0d9f..0458ddc7 100644 --- a/fragments/users.js +++ b/fragments/users.js @@ -12,6 +12,7 @@ export const ME = gql` freePosts freeComments tipDefault + turboTipping fiatCurrency bioId upvotePopover @@ -34,6 +35,7 @@ export const ME = gql` export const SETTINGS_FIELDS = gql` fragment SettingsFields on User { tipDefault + turboTipping fiatCurrency noteItemSats noteEarning @@ -65,12 +67,12 @@ ${SETTINGS_FIELDS} export const SET_SETTINGS = gql` ${SETTINGS_FIELDS} -mutation setSettings($tipDefault: Int!, $fiatCurrency: String!, $noteItemSats: Boolean!, $noteEarning: Boolean!, - $noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!, +mutation setSettings($tipDefault: Int!, $turboTipping: Boolean!, $fiatCurrency: String!, $noteItemSats: Boolean!, + $noteEarning: Boolean!, $noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!, $noteInvites: Boolean!, $noteJobIndicator: Boolean!, $hideInvoiceDesc: Boolean!, $hideFromTopUsers: Boolean!, $wildWestMode: Boolean!, $greeterMode: Boolean!) { - setSettings(tipDefault: $tipDefault, fiatCurrency: $fiatCurrency, noteItemSats: $noteItemSats, - noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants, + setSettings(tipDefault: $tipDefault, turboTipping: $turboTipping, fiatCurrency: $fiatCurrency, + noteItemSats: $noteItemSats, noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants, noteMentions: $noteMentions, noteDeposits: $noteDeposits, noteInvites: $noteInvites, noteJobIndicator: $noteJobIndicator, hideInvoiceDesc: $hideInvoiceDesc, hideFromTopUsers: $hideFromTopUsers, wildWestMode: $wildWestMode, greeterMode: $greeterMode) { diff --git a/pages/settings.js b/pages/settings.js index 41c75073..37793fc9 100644 --- a/pages/settings.js +++ b/pages/settings.js @@ -14,6 +14,7 @@ import { useRouter } from 'next/router' import Info from '../components/info' import { CURRENCY_SYMBOLS } from '../components/price' import Link from 'next/link' +import AccordianItem from '../components/accordian-item' export const getServerSideProps = getGetServerSideProps(SETTINGS) @@ -59,6 +60,7 @@ export default function Settings ({ data: { settings } }) {