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 { extend type Mutation {
setName(name: String!): Boolean setName(name: String!): Boolean
setSettings(tipDefault: Int!, fiatCurrency: String!, noteItemSats: Boolean!, noteEarning: Boolean!, setSettings(tipDefault: Int!, turboTipping: Boolean!, fiatCurrency: String!, noteItemSats: Boolean!,
noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!, noteEarning: Boolean!, noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!,
noteInvites: Boolean!, noteJobIndicator: Boolean!, hideInvoiceDesc: Boolean!, hideFromTopUsers: Boolean!, noteInvites: Boolean!, noteJobIndicator: Boolean!, hideInvoiceDesc: Boolean!, hideFromTopUsers: Boolean!,
wildWestMode: Boolean!, greeterMode: Boolean!): User wildWestMode: Boolean!, greeterMode: Boolean!): User
setPhoto(photoId: ID!): Int! setPhoto(photoId: ID!): Int!
@ -49,6 +49,7 @@ export default gql`
freeComments: Int! freeComments: Int!
hasInvites: Boolean! hasInvites: Boolean!
tipDefault: Int! tipDefault: Int!
turboTipping: Boolean!
fiatCurrency: String! fiatCurrency: String!
bio: Item bio: Item
bioId: Int bioId: Int

View File

@ -152,11 +152,19 @@ export default function UpVote ({ item, className }) {
} }
) )
const overlayText = () => { // what should our next tip be?
if (me?.tipDefault) { let sats = me?.tipDefault || 1
return `${me.tipDefault} sat${me.tipDefault > 1 ? 's' : ''}` 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) const color = getColor(item?.meSats)
@ -196,11 +204,11 @@ export default function UpVote ({ item, className }) {
try { try {
await act({ await act({
variables: { id: item.id, sats: me.tipDefault || 1 }, variables: { id: item.id, sats },
optimisticResponse: { optimisticResponse: {
act: { act: {
id: `Item:${item.id}`, id: `Item:${item.id}`,
sats: me.tipDefault || 1, sats,
vote: 0 vote: 0
} }
} }

View File

@ -12,6 +12,7 @@ export const ME = gql`
freePosts freePosts
freeComments freeComments
tipDefault tipDefault
turboTipping
fiatCurrency fiatCurrency
bioId bioId
upvotePopover upvotePopover
@ -34,6 +35,7 @@ export const ME = gql`
export const SETTINGS_FIELDS = gql` export const SETTINGS_FIELDS = gql`
fragment SettingsFields on User { fragment SettingsFields on User {
tipDefault tipDefault
turboTipping
fiatCurrency fiatCurrency
noteItemSats noteItemSats
noteEarning noteEarning
@ -65,12 +67,12 @@ ${SETTINGS_FIELDS}
export const SET_SETTINGS = export const SET_SETTINGS =
gql` gql`
${SETTINGS_FIELDS} ${SETTINGS_FIELDS}
mutation setSettings($tipDefault: Int!, $fiatCurrency: String!, $noteItemSats: Boolean!, $noteEarning: Boolean!, mutation setSettings($tipDefault: Int!, $turboTipping: Boolean!, $fiatCurrency: String!, $noteItemSats: Boolean!,
$noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!, $noteEarning: Boolean!, $noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!,
$noteInvites: Boolean!, $noteJobIndicator: Boolean!, $hideInvoiceDesc: Boolean!, $hideFromTopUsers: Boolean!, $noteInvites: Boolean!, $noteJobIndicator: Boolean!, $hideInvoiceDesc: Boolean!, $hideFromTopUsers: Boolean!,
$wildWestMode: Boolean!, $greeterMode: Boolean!) { $wildWestMode: Boolean!, $greeterMode: Boolean!) {
setSettings(tipDefault: $tipDefault, fiatCurrency: $fiatCurrency, noteItemSats: $noteItemSats, setSettings(tipDefault: $tipDefault, turboTipping: $turboTipping, fiatCurrency: $fiatCurrency,
noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants, noteItemSats: $noteItemSats, noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants,
noteMentions: $noteMentions, noteDeposits: $noteDeposits, noteInvites: $noteInvites, noteMentions: $noteMentions, noteDeposits: $noteDeposits, noteInvites: $noteInvites,
noteJobIndicator: $noteJobIndicator, hideInvoiceDesc: $hideInvoiceDesc, hideFromTopUsers: $hideFromTopUsers, noteJobIndicator: $noteJobIndicator, hideInvoiceDesc: $hideInvoiceDesc, hideFromTopUsers: $hideFromTopUsers,
wildWestMode: $wildWestMode, greeterMode: $greeterMode) { wildWestMode: $wildWestMode, greeterMode: $greeterMode) {

View File

@ -14,6 +14,7 @@ import { useRouter } from 'next/router'
import Info from '../components/info' import Info from '../components/info'
import { CURRENCY_SYMBOLS } from '../components/price' import { CURRENCY_SYMBOLS } from '../components/price'
import Link from 'next/link' import Link from 'next/link'
import AccordianItem from '../components/accordian-item'
export const getServerSideProps = getGetServerSideProps(SETTINGS) export const getServerSideProps = getGetServerSideProps(SETTINGS)
@ -59,6 +60,7 @@ export default function Settings ({ data: { settings } }) {
<Form <Form
initial={{ initial={{
tipDefault: settings?.tipDefault || 21, tipDefault: settings?.tipDefault || 21,
turboTipping: settings?.turboTipping,
fiatCurrency: settings?.fiatCurrency || 'USD', fiatCurrency: settings?.fiatCurrency || 'USD',
noteItemSats: settings?.noteItemSats, noteItemSats: settings?.noteItemSats,
noteEarning: settings?.noteEarning, noteEarning: settings?.noteEarning,
@ -82,10 +84,44 @@ export default function Settings ({ data: { settings } }) {
<Input <Input
label='tip default' label='tip default'
name='tipDefault' name='tipDefault'
groupClassName='mb-0'
required required
autoFocus autoFocus
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>} 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 <Select
label='fiat currency' label='fiat currency'
name='fiatCurrency' 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) freeComments Int @default(5)
freePosts Int @default(2) freePosts Int @default(2)
checkedNotesAt DateTime? checkedNotesAt DateTime?
tipDefault Int @default(10)
fiatCurrency String @default("USD") fiatCurrency String @default("USD")
pubkey String? @unique pubkey String? @unique
trust Float @default(0) trust Float @default(0)
@ -48,6 +47,10 @@ model User {
upvotePopover Boolean @default(false) upvotePopover Boolean @default(false)
tipPopover Boolean @default(false) tipPopover Boolean @default(false)
// tip settings
tipDefault Int @default(10)
turboTipping Boolean @default(false)
// notification settings // notification settings
noteItemSats Boolean @default(true) noteItemSats Boolean @default(true)
noteEarning Boolean @default(true) noteEarning Boolean @default(true)