UI tweaks and nits for starter packs (#4548)

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Co-authored-by: Eric Bailey <git@esb.lol>
Co-authored-by: Samuel Newman <mozzius@protonmail.com>
fix truncation on native (#4575)
This commit is contained in:
Hailey
2024-06-19 15:09:00 -07:00
committed by GitHub
parent 50a61f1084
commit b283fbd484
42 changed files with 615 additions and 486 deletions
+24 -13
View File
@@ -34,16 +34,14 @@ export const createStarterPackList = async ({
if (!list) throw new Error('List creation failed')
await agent.com.atproto.repo.applyWrites({
repo: agent.session!.did,
writes: profiles.map(p => ({
$type: 'com.atproto.repo.applyWrites#create',
collection: 'app.bsky.graph.listitem',
value: {
$type: 'app.bsky.graph.listitem',
subject: p.did,
list: list?.uri,
createdAt: new Date().toISOString(),
},
})),
writes: [
createListItem({did: agent.session!.did, listUri: list.uri}),
].concat(
profiles
// Ensure we don't have ourselves in this list twice
.filter(p => p.did !== agent.session!.did)
.map(p => createListItem({did: p.did, listUri: list.uri})),
),
})
return list
@@ -80,8 +78,8 @@ export async function generateStarterpack({
return 'ERROR'
}
profiles = [profile, ...profiles]
if (profiles.length < 8) {
// We include ourselves when we make the list
if (profiles.length < 7) {
return 'NOT_ENOUGH_FOLLOWERS'
}
@@ -111,7 +109,20 @@ export async function generateStarterpack({
)
).uri
} catch (e: unknown) {
logger.error('Failed to generate starter pack', {error: e})
logger.error('Failed to generate starter pack', {safeMessage: e})
return 'ERROR'
}
}
function createListItem({did, listUri}: {did: string; listUri: string}) {
return {
$type: 'com.atproto.repo.applyWrites#create',
collection: 'app.bsky.graph.listitem',
value: {
$type: 'app.bsky.graph.listitem',
subject: did,
list: listUri,
createdAt: new Date().toISOString(),
},
}
}