From 4be5286122514d678b45cef4661fb2ee6649eb90 Mon Sep 17 00:00:00 2001 From: keyan Date: Mon, 1 May 2023 16:49:47 -0500 Subject: [PATCH] hide cowboy hat setting --- api/resolvers/user.js | 2 +- api/typeDefs/user.js | 4 +++- components/cowboy-hat.js | 5 +++-- components/header.js | 4 ++-- components/item-info.js | 2 +- components/item-job.js | 2 +- components/user-header.js | 2 +- components/user-list.js | 2 +- fragments/comments.js | 2 ++ fragments/invites.js | 1 + fragments/items.js | 3 +++ fragments/users.js | 12 ++++++++++-- pages/settings.js | 6 ++++++ .../20230501205951_hide_cowboy/migration.sql | 2 ++ .../20230501212659_hide_cowboy_rename/migration.sql | 2 ++ prisma/schema.prisma | 1 + 16 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 prisma/migrations/20230501205951_hide_cowboy/migration.sql create mode 100644 prisma/migrations/20230501212659_hide_cowboy_rename/migration.sql diff --git a/api/resolvers/user.js b/api/resolvers/user.js index a30dad13..bbc8694f 100644 --- a/api/resolvers/user.js +++ b/api/resolvers/user.js @@ -95,7 +95,7 @@ export default { const users = await models.$queryRaw(` SELECT users.* FROM users - WHERE NOT "hideFromTopUsers" AND streak IS NOT NULL + WHERE NOT "hideFromTopUsers" AND NOT "hideCowboyHat" AND streak IS NOT NULL ORDER BY streak DESC, created_at ASC OFFSET $1 LIMIT ${LIMIT}`, decodedCursor.offset) diff --git a/api/typeDefs/user.js b/api/typeDefs/user.js index b5172a49..85ceeaf5 100644 --- a/api/typeDefs/user.js +++ b/api/typeDefs/user.js @@ -22,7 +22,8 @@ export default gql` setName(name: String!): Boolean setSettings(tipDefault: Int!, turboTipping: Boolean!, fiatCurrency: String!, noteItemSats: Boolean!, noteEarning: Boolean!, noteAllDescendants: Boolean!, noteMentions: Boolean!, noteDeposits: Boolean!, - noteInvites: Boolean!, noteJobIndicator: Boolean!, noteCowboyHat: Boolean!, hideInvoiceDesc: Boolean!, hideFromTopUsers: Boolean!, + noteInvites: Boolean!, noteJobIndicator: Boolean!, noteCowboyHat: Boolean!, hideInvoiceDesc: Boolean!, + hideFromTopUsers: Boolean!, hideCowboyHat: Boolean!, wildWestMode: Boolean!, greeterMode: Boolean!, nostrPubkey: String, nostrRelays: [String!]): User setPhoto(photoId: ID!): Int! upsertBio(bio: String!): User! @@ -74,6 +75,7 @@ export default gql` noteCowboyHat: Boolean! hideInvoiceDesc: Boolean! hideFromTopUsers: Boolean! + hideCowboyHat: Boolean! wildWestMode: Boolean! greeterMode: Boolean! lastCheckedJobs: String diff --git a/components/cowboy-hat.js b/components/cowboy-hat.js index 3dd841db..9e02c334 100644 --- a/components/cowboy-hat.js +++ b/components/cowboy-hat.js @@ -1,11 +1,12 @@ import { Badge, OverlayTrigger, Tooltip } from 'react-bootstrap' import CowboyHatIcon from '../svgs/cowboy.svg' -export default function CowboyHat ({ streak, badge, className = 'ml-1', height = 16, width = 16 }) { - if (streak === null) { +export default function CowboyHat ({ user, badge, className = 'ml-1', height = 16, width = 16 }) { + if (user?.streak === null || user.hideCowboyHat) { return null } + const streak = user.streak return ( {badge diff --git a/components/header.js b/components/header.js index 17397790..77e84bc1 100644 --- a/components/header.js +++ b/components/header.js @@ -86,7 +86,7 @@ export default function Header ({ sub }) { e.preventDefault()}> - {`@${me?.name}`} + {`@${me?.name}`} } alignRight > @@ -152,7 +152,7 @@ export default function Header ({ sub }) { }, []) } return path !== '/login' && path !== '/signup' && !path.startsWith('/invites') && -
+
}
diff --git a/components/user-list.js b/components/user-list.js index 971f4ceb..97a80a3b 100644 --- a/components/user-list.js +++ b/components/user-list.js @@ -20,7 +20,7 @@ export default function UserList ({ users }) {
- @{user.name} + @{user.name}
diff --git a/fragments/comments.js b/fragments/comments.js index 059127fa..96b1ca0a 100644 --- a/fragments/comments.js +++ b/fragments/comments.js @@ -10,6 +10,7 @@ export const COMMENT_FIELDS = gql` user { name streak + hideCowboyHat id } sats @@ -33,6 +34,7 @@ export const COMMENT_FIELDS = gql` user { name streak + hideCowboyHat id } } diff --git a/fragments/invites.js b/fragments/invites.js index 68a03fb7..236d3c59 100644 --- a/fragments/invites.js +++ b/fragments/invites.js @@ -14,6 +14,7 @@ export const INVITE_FIELDS = gql` user { name streak + hideCowboyHat id } poor diff --git a/fragments/items.js b/fragments/items.js index 78fd8abd..915d8824 100644 --- a/fragments/items.js +++ b/fragments/items.js @@ -12,6 +12,7 @@ export const ITEM_FIELDS = gql` user { name streak + hideCowboyHat id } fwdUserId @@ -54,6 +55,7 @@ export const ITEM_FULL_FIELDS = gql` fwdUser { name streak + hideCowboyHat id } root { @@ -67,6 +69,7 @@ export const ITEM_FULL_FIELDS = gql` user { name streak + hideCowboyHat id } } diff --git a/fragments/users.js b/fragments/users.js index 5d56598b..27e95b53 100644 --- a/fragments/users.js +++ b/fragments/users.js @@ -28,6 +28,7 @@ export const ME = gql` noteCowboyHat hideInvoiceDesc hideFromTopUsers + hideCowboyHat wildWestMode greeterMode lastCheckedJobs @@ -49,6 +50,7 @@ export const SETTINGS_FIELDS = gql` noteCowboyHat hideInvoiceDesc hideFromTopUsers + hideCowboyHat nostrPubkey nostrRelays wildWestMode @@ -75,12 +77,14 @@ gql` ${SETTINGS_FIELDS} mutation setSettings($tipDefault: Int!, $turboTipping: Boolean!, $fiatCurrency: String!, $noteItemSats: Boolean!, $noteEarning: Boolean!, $noteAllDescendants: Boolean!, $noteMentions: Boolean!, $noteDeposits: Boolean!, - $noteInvites: Boolean!, $noteJobIndicator: Boolean!, $noteCowboyHat: Boolean!, $hideInvoiceDesc: Boolean!, $hideFromTopUsers: Boolean!, + $noteInvites: Boolean!, $noteJobIndicator: Boolean!, $noteCowboyHat: Boolean!, $hideInvoiceDesc: Boolean!, + $hideFromTopUsers: Boolean!, $hideCowboyHat: Boolean!, $wildWestMode: Boolean!, $greeterMode: Boolean!, $nostrPubkey: String, $nostrRelays: [String!]) { setSettings(tipDefault: $tipDefault, turboTipping: $turboTipping, fiatCurrency: $fiatCurrency, noteItemSats: $noteItemSats, noteEarning: $noteEarning, noteAllDescendants: $noteAllDescendants, noteMentions: $noteMentions, noteDeposits: $noteDeposits, noteInvites: $noteInvites, - noteJobIndicator: $noteJobIndicator, noteCowboyHat: $noteCowboyHat, hideInvoiceDesc: $hideInvoiceDesc, hideFromTopUsers: $hideFromTopUsers, + noteJobIndicator: $noteJobIndicator, noteCowboyHat: $noteCowboyHat, hideInvoiceDesc: $hideInvoiceDesc, + hideFromTopUsers: $hideFromTopUsers, hideCowboyHat: $hideCowboyHat, wildWestMode: $wildWestMode, greeterMode: $greeterMode, nostrPubkey: $nostrPubkey, nostrRelays: $nostrRelays) { ...SettingsFields } @@ -107,6 +111,7 @@ gql` searchUsers(q: $q, limit: $limit, similarity: $similarity) { name streak + hideCowboyHat photoId stacked spent @@ -122,6 +127,7 @@ export const USER_FIELDS = gql` createdAt name streak + hideCowboyHat nitems ncomments nbookmarks @@ -140,6 +146,7 @@ export const TOP_USERS = gql` users { name streak + hideCowboyHat photoId stacked(when: $when) spent(when: $when) @@ -158,6 +165,7 @@ export const TOP_COWBOYS = gql` users { name streak + hideCowboyHat photoId stacked(when: "forever") spent(when: "forever") diff --git a/pages/settings.js b/pages/settings.js index 9abd373b..4bef4079 100644 --- a/pages/settings.js +++ b/pages/settings.js @@ -64,6 +64,7 @@ export default function Settings ({ data: { settings } }) { noteCowboyHat: settings?.noteCowboyHat, hideInvoiceDesc: settings?.hideInvoiceDesc, hideFromTopUsers: settings?.hideFromTopUsers, + hideCowboyHat: settings?.hideCowboyHat, wildWestMode: settings?.wildWestMode, greeterMode: settings?.greeterMode, nostrPubkey: settings?.nostrPubkey ? bech32encode(settings.nostrPubkey) : '', @@ -205,6 +206,11 @@ export default function Settings ({ data: { settings } }) { hide me from top users} name='hideFromTopUsers' + groupClassName='mb-0' + /> + hide my cowboy hat} + name='hideCowboyHat' />
content