Only suggest users in invite suggestions

zio/stable
Paul Frazee 2022-11-11 10:17:14 -06:00
parent cc015d1686
commit 3a0e9f52f3
3 changed files with 10 additions and 11 deletions

View File

@ -2,28 +2,26 @@ import {makeAutoObservable, runInAction} from 'mobx'
import {RootStoreModel} from './root-store'
import {MembersViewModel} from './members-view'
import {UserFollowsViewModel, FollowItem} from './user-follows-view'
import {APP_BSKY_SYSTEM} from '../../third-party/api'
export interface SceneInviteSuggestionsParams {
export interface SuggestedInvites {
sceneDid: string
}
export class SceneInviteSuggestions {
export class SuggestedInvites {
// state
isLoading = false
isRefreshing = false
hasLoaded = false
error = ''
params: SceneInviteSuggestionsParams
params: SuggestedInvites
sceneMembersView: MembersViewModel
myFollowsView: UserFollowsViewModel
// data
suggestions: FollowItem[] = []
constructor(
public rootStore: RootStoreModel,
params: SceneInviteSuggestionsParams,
) {
constructor(public rootStore: RootStoreModel, params: SuggestedInvites) {
makeAutoObservable(
this,
{
@ -111,7 +109,9 @@ export class SceneInviteSuggestions {
// collect all followed users that arent already in the scene
const newSuggestions: FollowItem[] = []
for (const follow of this.myFollowsView.follows) {
// TODO: filter out scenes
if (follow.declaration.actorType !== APP_BSKY_SYSTEM.ActorUser) {
continue
}
if (
!this.sceneMembersView.members.find(member => member.did === follow.did)
) {

View File

@ -23,7 +23,7 @@ import {ErrorMessage} from '../util/ErrorMessage'
import {useStores} from '../../../state'
import * as apilib from '../../../state/lib/api'
import {ProfileViewModel} from '../../../state/models/profile-view'
import {SceneInviteSuggestions} from '../../../state/models/scene-invite-suggestions'
import {SuggestedInvites} from '../../../state/models/suggested-invites'
import {FollowItem} from '../../../state/models/user-follows-view'
import {s, colors} from '../../lib/styles'
@ -40,7 +40,7 @@ export function Component({profileView}: {profileView: ProfileViewModel}) {
const [hasSetup, setHasSetup] = useState<boolean>(false)
const [error, setError] = useState<string>('')
const suggestions = useMemo(
() => new SceneInviteSuggestions(store, {sceneDid: profileView.did}),
() => new SuggestedInvites(store, {sceneDid: profileView.did}),
[profileView.did],
)
const [createdInvites, setCreatedInvites] = useState<Record<string, string>>(

View File

@ -16,7 +16,6 @@ Paul's todo list
- *
- Invite to scene
- User search
> Filter out scenes from suggestions
> Filter out unconfirmed invites from suggestions
- Use pagination to make sure there are suggestions
- Unconfirmed invites