turbo tipping

This commit is contained in:
keyan 2022-12-09 13:25:38 -06:00
parent e1bdb9c769
commit 7b7ed0047c
6 changed files with 65 additions and 13 deletions

View File

@ -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

View File

@ -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
}
}

View File

@ -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) {

View File

@ -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 } }) {
<Form
initial={{
tipDefault: settings?.tipDefault || 21,
turboTipping: settings?.turboTipping,
fiatCurrency: settings?.fiatCurrency || 'USD',
noteItemSats: settings?.noteItemSats,
noteEarning: settings?.noteEarning,
@ -82,10 +84,44 @@ export default function Settings ({ data: { settings } }) {
<Input
label='tip default'
name='tipDefault'
groupClassName='mb-0'
required
autoFocus
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
hint={<small className='text-muted'>note: you can also press and hold the lightning bolt to tip custom amounts</small>}
/>
<div className='mb-2'>
<AccordianItem
show={settings?.turboTipping}
header={<div style={{ fontWeight: 'bold', fontSize: '92%' }}>advanced</div>}
body={<Checkbox
name='turboTipping'
label={
<div className='d-flex align-items-center'>turbo tipping
<Info>
<ul className='font-weight-bold'>
<li>Makes every additional bolt click raise your total tip to another 10x multiple of your default tip</li>
<li>e.g. if your tip default is 10 sats
<ul>
<li>1st click: 10 sats total tipped</li>
<li>2nd click: 100 sats total tipped</li>
<li>3rd click: 1000 sats total tipped</li>
<li>4th click: 10000 sats total tipped</li>
<li>and so on ...</li>
</ul>
</li>
<li>You can still custom tip via long press
<ul>
<li>the next bolt click rounds up to the next greatest 10x multiple of your default</li>
</ul>
</li>
</ul>
</Info>
</div>
}
/>}
/>
</div>
<Select
label='fiat currency'
name='fiatCurrency'

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "turboTipping" BOOLEAN NOT NULL DEFAULT false;

View File

@ -35,7 +35,6 @@ model User {
freeComments Int @default(5)
freePosts Int @default(2)
checkedNotesAt DateTime?
tipDefault Int @default(10)
fiatCurrency String @default("USD")
pubkey String? @unique
trust Float @default(0)
@ -48,6 +47,10 @@ model User {
upvotePopover Boolean @default(false)
tipPopover Boolean @default(false)
// tip settings
tipDefault Int @default(10)
turboTipping Boolean @default(false)
// notification settings
noteItemSats Boolean @default(true)
noteEarning Boolean @default(true)