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:
@@ -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(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ export type CommonNavigatorParams = {
|
||||
MessagesConversation: {conversation: string; embed?: string}
|
||||
MessagesSettings: undefined
|
||||
Feeds: undefined
|
||||
Start: {name: string; rkey: string}
|
||||
StarterPack: {name: string; rkey: string}
|
||||
StarterPackWizard: undefined
|
||||
StarterPackEdit: {
|
||||
@@ -98,6 +99,7 @@ export type AllNavigatorParams = CommonNavigatorParams & {
|
||||
Hashtag: {tag: string; author?: string}
|
||||
MessagesTab: undefined
|
||||
Messages: {animation?: 'push' | 'pop'}
|
||||
Start: {name: string; rkey: string}
|
||||
StarterPack: {name: string; rkey: string}
|
||||
StarterPackWizard: undefined
|
||||
StarterPackEdit: {
|
||||
|
||||
@@ -155,7 +155,7 @@ export type LogEvents = {
|
||||
'starterPack:share': {
|
||||
starterPack: string
|
||||
shareType: 'link' | 'qrcode'
|
||||
qrShareType?: 'save' | 'copy'
|
||||
qrShareType?: 'save' | 'copy' | 'share'
|
||||
}
|
||||
'starterPack:followAll': {
|
||||
starterPack: string
|
||||
|
||||
@@ -14,8 +14,8 @@ export function createStarterPackLinkFromAndroidReferrer(
|
||||
if (!utmContent) return null
|
||||
if (utmSource !== 'bluesky') return null
|
||||
|
||||
// This should be a string like `starterpack-haileyok.com-rkey`
|
||||
const contentParts = utmContent.split('-')
|
||||
// This should be a string like `starterpack_haileyok.com_rkey`
|
||||
const contentParts = utmContent.split('_')
|
||||
|
||||
if (contentParts[0] !== 'starterpack') return null
|
||||
if (contentParts.length !== 3) return null
|
||||
@@ -46,10 +46,10 @@ export function parseStarterPackUri(uri?: string): {
|
||||
} else {
|
||||
const url = new URL(uri)
|
||||
const parts = url.pathname.split('/')
|
||||
const name = parts[2]
|
||||
const rkey = parts[3]
|
||||
const [_, path, name, rkey] = parts
|
||||
|
||||
if (parts.length !== 4) return null
|
||||
if (path !== 'starter-pack' && path !== 'start') return null
|
||||
if (!name || !rkey) return null
|
||||
return {
|
||||
name,
|
||||
@@ -66,7 +66,7 @@ export function createStarterPackGooglePlayUri(
|
||||
rkey: string,
|
||||
): string | null {
|
||||
if (!name || !rkey) return null
|
||||
return `https://play.google.com/store/apps/details?id=xyz.blueskyweb.app&referrer=utm_source%3Dbluesky%26utm_medium%3Dstarterpack%26utm_content%3Dstarterpack-${name}-${rkey}`
|
||||
return `https://play.google.com/store/apps/details?id=xyz.blueskyweb.app&referrer=utm_source%3Dbluesky%26utm_medium%3Dstarterpack%26utm_content%3Dstarterpack_${name}_${rkey}`
|
||||
}
|
||||
|
||||
export function httpStarterPackUriToAtUri(httpUri?: string): string | null {
|
||||
|
||||
Reference in New Issue
Block a user