diff --git a/common/user.ts b/common/user.ts index 477139fd..2960bda0 100644 --- a/common/user.ts +++ b/common/user.ts @@ -38,6 +38,7 @@ export type User = { referredByUserId?: string referredByContractId?: string + lastPingTime?: number } export const STARTING_BALANCE = ENV_CONFIG.startingBalance ?? 1000 @@ -57,7 +58,6 @@ export type PrivateUser = { initialIpAddress?: string apiKey?: string notificationPreferences?: notification_subscribe_types - lastTimeCheckedBonuses?: number } export type notification_subscribe_types = 'all' | 'less' | 'none' diff --git a/firestore.rules b/firestore.rules index 918448d6..196c5992 100644 --- a/firestore.rules +++ b/firestore.rules @@ -20,16 +20,17 @@ service cloud.firestore { allow read; allow update: if resource.data.id == request.auth.uid && request.resource.data.diff(resource.data).affectedKeys() - .hasOnly(['bio', 'bannerUrl', 'website', 'twitterHandle', 'discordHandle', 'followedCategories', 'referredByContractId']); - allow update: if resource.data.id == request.auth.uid - && request.resource.data.diff(resource.data).affectedKeys() - .hasOnly(['referredByUserId']) - // only one referral allowed per user - && !("referredByUserId" in resource.data) - // user can't refer themselves - && !(resource.data.id == request.resource.data.referredByUserId); - // quid pro quos enabled (only once though so nbd) - bc I can't make this work: - // && (get(/databases/$(database)/documents/users/$(request.resource.data.referredByUserId)).referredByUserId == resource.data.id); + .hasOnly(['bio', 'bannerUrl', 'website', 'twitterHandle', 'discordHandle', 'followedCategories', 'referredByContractId', 'lastPingTime']); + // User referral rules + allow update: if resource.data.id == request.auth.uid + && request.resource.data.diff(resource.data).affectedKeys() + .hasOnly(['referredByUserId']) + // only one referral allowed per user + && !("referredByUserId" in resource.data) + // user can't refer themselves + && !(resource.data.id == request.resource.data.referredByUserId); + // quid pro quos enabled (only once though so nbd) - bc I can't make this work: + // && (get(/databases/$(database)/documents/users/$(request.resource.data.referredByUserId)).referredByUserId == resource.data.id); } match /{somePath=**}/portfolioHistory/{portfolioHistoryId} { diff --git a/web/components/follow-list.tsx b/web/components/follow-list.tsx index c935f73d..391ce4d3 100644 --- a/web/components/follow-list.tsx +++ b/web/components/follow-list.tsx @@ -7,6 +7,7 @@ import { FollowButton } from './follow-button' import { Col } from './layout/col' import { Row } from './layout/row' import { UserLink } from './user-page' +import { OnlineUserAvatar } from 'web/components/online-user-list' export function FollowList(props: { userIds: string[] }) { const { userIds } = props @@ -63,10 +64,7 @@ function UserFollowItem(props: { return ( - - - {user && } - + {!hideFollowButton && ( { + if (!user) return + // set ping time to now every 60 seconds to indicate that the user is active + const pingInterval = setInterval(() => { + updateUser(user.id, { + lastPingTime: Date.now(), + }) + }, 1000 * 30) + return () => clearInterval(pingInterval) + }, [user]) + return (