Skip to content

Commit

Permalink
allow pins to be zapped but not from pin position
Browse files Browse the repository at this point in the history
  • Loading branch information
huumn committed Feb 3, 2024
1 parent cb5c12b commit c23f1f8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 0 additions & 2 deletions api/resolvers/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ export default {
${relationClause(type)}
${joinZapRankPersonalView(me, models)}
${whereClause(
'"Item"."pinId" IS NULL',
'"Item"."deletedAt" IS NULL',
subClause(sub, 5, subClauseTable(type), me),
typeClause(type),
Expand All @@ -389,7 +388,6 @@ export default {
${selectClause(type)}
${relationClause(type)}
${whereClause(
'"Item"."pinId" IS NULL',
'"Item"."deletedAt" IS NULL',
subClause(sub, 5, subClauseTable(type), me),
typeClause(type),
Expand Down
4 changes: 2 additions & 2 deletions components/item-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { MuteSubDropdownItem, PinSubDropdownItem } from './territory-header'
export default function ItemInfo ({
item, full, commentsText = 'comments',
commentTextSingular = 'comment', className, embellishUser, extraInfo, onEdit, editText,
onQuoteReply, nofollow, extraBadges, nested
onQuoteReply, nofollow, extraBadges, nested, pinnable
}) {
const editThreshold = new Date(item.createdAt).getTime() + 10 * 60000
const me = useMe()
Expand Down Expand Up @@ -57,7 +57,7 @@ export default function ItemInfo ({

return (
<div className={className || `${styles.other}`}>
{!item.position && !(!item.parentId && Number(item.user?.id) === AD_USER_ID) &&
{!(item.position && (pinnable || !item.subName)) && !(!item.parentId && Number(item.user?.id) === AD_USER_ID) &&
<>
<span title={`from ${numWithUnits(item.upvotes, {
abbreviate: false,
Expand Down
5 changes: 3 additions & 2 deletions components/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function SearchTitle ({ title }) {
})
}

export default function Item ({ item, rank, belowTitle, right, full, children, siblingComments, onQuoteReply }) {
export default function Item ({ item, rank, belowTitle, right, full, children, siblingComments, onQuoteReply, pinnable }) {
const titleRef = useRef()
const router = useRouter()

Expand All @@ -40,7 +40,7 @@ export default function Item ({ item, rank, belowTitle, right, full, children, s
</div>)
: <div />}
<div className={`${styles.item} ${siblingComments ? 'pt-3' : ''}`}>
{item.position
{item.position && (pinnable || !item.subName)
? <Pin width={24} height={24} className={styles.pin} />
: item.meDontLikeSats > item.meSats
? <DownZap width={24} height={24} className={styles.dontLike} id={item.id} meDontLikeSats={item.meDontLikeSats} />
Expand Down Expand Up @@ -95,6 +95,7 @@ export default function Item ({ item, rank, belowTitle, right, full, children, s
full={full} item={item}
onQuoteReply={onQuoteReply}
nofollow={nofollow}
pinnable={pinnable}
extraBadges={Number(item?.user?.id) === AD_USER_ID && <Badge className={styles.newComment} bg={null}>AD</Badge>}
/>
{belowTitle}
Expand Down
2 changes: 1 addition & 1 deletion components/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Items ({ ssrData, variables = {}, query, destructureData
<>
<div className={styles.grid}>
{itemsWithPins.filter(filter).map((item, i) => (
<ListItem key={item.id} item={item} rank={rank && i + 1} siblingComments={variables.includeComments} />
<ListItem key={item.id} item={item} rank={rank && i + 1} siblingComments={variables.includeComments} pinnable={pins?.length > 0} />
))}
</div>
<Foooter
Expand Down

0 comments on commit c23f1f8

Please sign in to comment.