Replace mock-api with real api
This commit is contained in:
parent
5193a5b48e
commit
aabde2b401
110 changed files with 16045 additions and 3742 deletions
|
@ -15,7 +15,7 @@ const WARNING_TEXT_LENGTH = 200
|
|||
const DANGER_TEXT_LENGTH = 255
|
||||
export const snapPoints = ['100%']
|
||||
|
||||
const DEBUG_USERNAMES = ['alice.com', 'bob.com', 'carla.com']
|
||||
const DEBUG_USERNAMES = ['alice.test', 'bob.test', 'carol.test']
|
||||
|
||||
export function Component({replyTo}: {replyTo?: string}) {
|
||||
const store = useStores()
|
||||
|
@ -48,7 +48,7 @@ export function Component({replyTo}: {replyTo?: string}) {
|
|||
return false
|
||||
}
|
||||
try {
|
||||
await apilib.post(store.api, 'alice.com', text, replyTo)
|
||||
await apilib.post(store.api, 'alice.test', text, replyTo)
|
||||
} catch (e: any) {
|
||||
console.error(`Failed to create post: ${e.toString()}`)
|
||||
setError(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React, {useMemo} from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
|
||||
import {AdxUri} from '@adxp/mock-api'
|
||||
import {Image, StyleSheet, Text, View} from 'react-native'
|
||||
import {AdxUri} from '../../../third-party/uri'
|
||||
import {FontAwesomeIcon, Props} from '@fortawesome/react-native-fontawesome'
|
||||
import {NotificationsViewItemModel} from '../../../state/models/notifications-view'
|
||||
import {s, colors} from '../../lib/styles'
|
||||
|
@ -64,7 +64,7 @@ export const FeedItem = observer(function FeedItem({
|
|||
<Link style={styles.layoutAvi} href={authorHref} title={authorTitle}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.author.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.author.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</Link>
|
||||
<View style={styles.layoutContent}>
|
||||
|
|
|
@ -80,7 +80,7 @@ const LikedByItem = ({item}: {item: LikedByViewItemModel}) => {
|
|||
<View style={styles.layoutAvi}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.layoutContent}>
|
||||
|
|
|
@ -86,7 +86,7 @@ const RepostedByItem = ({item}: {item: RepostedByViewItemModel}) => {
|
|||
<View style={styles.layoutAvi}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.layoutContent}>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import React, {useMemo} from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
|
||||
import {bsky, AdxUri} from '@adxp/mock-api'
|
||||
import {AdxUri} from '../../../third-party/uri'
|
||||
import * as PostType from '../../../third-party/api/src/types/todo/social/post'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {PostThreadViewPostModel} from '../../../state/models/post-thread-view'
|
||||
import {ComposePostModel} from '../../../state/models/shell'
|
||||
|
@ -20,7 +21,7 @@ export const PostThreadItem = observer(function PostThreadItem({
|
|||
onPressShare: (_uri: string) => void
|
||||
}) {
|
||||
const store = useStores()
|
||||
const record = item.record as unknown as bsky.Post.Record
|
||||
const record = item.record as unknown as PostType.Record
|
||||
const hasEngagement = item.likeCount || item.repostCount
|
||||
|
||||
const itemHref = useMemo(() => {
|
||||
|
@ -68,23 +69,22 @@ export const PostThreadItem = observer(function PostThreadItem({
|
|||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleRepost}>
|
||||
<FontAwesomeIcon
|
||||
style={
|
||||
item.myState.hasReposted ? styles.ctrlIconReposted : styles.ctrlIcon
|
||||
item.myState.repost ? styles.ctrlIconReposted : styles.ctrlIcon
|
||||
}
|
||||
icon="retweet"
|
||||
size={18}
|
||||
/>
|
||||
<Text
|
||||
style={item.myState.hasReposted ? [s.bold, s.green3, s.f13] : s.f13}>
|
||||
<Text style={item.myState.repost ? [s.bold, s.green3, s.f13] : s.f13}>
|
||||
{item.repostCount}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleLike}>
|
||||
<FontAwesomeIcon
|
||||
style={item.myState.hasLiked ? styles.ctrlIconLiked : styles.ctrlIcon}
|
||||
icon={[item.myState.hasLiked ? 'fas' : 'far', 'heart']}
|
||||
style={item.myState.like ? styles.ctrlIconLiked : styles.ctrlIcon}
|
||||
icon={[item.myState.like ? 'fas' : 'far', 'heart']}
|
||||
size={14}
|
||||
/>
|
||||
<Text style={item.myState.hasLiked ? [s.bold, s.red3, s.f13] : s.f13}>
|
||||
<Text style={item.myState.like ? [s.bold, s.red3, s.f13] : s.f13}>
|
||||
{item.likeCount}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
@ -107,7 +107,7 @@ export const PostThreadItem = observer(function PostThreadItem({
|
|||
<Link style={styles.layoutAvi} href={authorHref} title={authorTitle}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.author.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.author.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</Link>
|
||||
<View style={styles.layoutContent}>
|
||||
|
@ -192,7 +192,7 @@ export const PostThreadItem = observer(function PostThreadItem({
|
|||
<Link style={styles.layoutAvi} href={authorHref} title={authorTitle}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.author.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.author.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</Link>
|
||||
<View style={styles.layoutContent}>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import React, {useState, useEffect} from 'react'
|
||||
import React, {useState, useEffect, useMemo} from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {bsky, AdxUri} from '@adxp/mock-api'
|
||||
import {AdxUri} from '../../../third-party/uri'
|
||||
import * as PostType from '../../../third-party/api/src/types/todo/social/post'
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Image,
|
||||
|
@ -54,7 +55,7 @@ export const Post = observer(function Post({uri}: {uri: string}) {
|
|||
// loaded
|
||||
// =
|
||||
const item = view.thread
|
||||
const record = view.thread?.record as unknown as bsky.Post.Record
|
||||
const record = view.thread?.record as unknown as PostType.Record
|
||||
|
||||
const itemHref = useMemo(() => {
|
||||
const urip = new AdxUri(item.uri)
|
||||
|
@ -83,7 +84,7 @@ export const Post = observer(function Post({uri}: {uri: string}) {
|
|||
<Link style={styles.layoutAvi} href={authorHref} title={authorTitle}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.author.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.author.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</Link>
|
||||
<View style={styles.layoutContent}>
|
||||
|
@ -112,7 +113,7 @@ export const Post = observer(function Post({uri}: {uri: string}) {
|
|||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleRepost}>
|
||||
<FontAwesomeIcon
|
||||
style={
|
||||
item.myState.hasReposted
|
||||
item.myState.repost
|
||||
? styles.ctrlIconReposted
|
||||
: styles.ctrlIcon
|
||||
}
|
||||
|
@ -120,21 +121,18 @@ export const Post = observer(function Post({uri}: {uri: string}) {
|
|||
size={22}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
item.myState.hasReposted ? [s.bold, s.green3] : undefined
|
||||
}>
|
||||
style={item.myState.repost ? [s.bold, s.green3] : undefined}>
|
||||
{item.repostCount}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleLike}>
|
||||
<FontAwesomeIcon
|
||||
style={
|
||||
item.myState.hasLiked ? styles.ctrlIconLiked : styles.ctrlIcon
|
||||
item.myState.like ? styles.ctrlIconLiked : styles.ctrlIcon
|
||||
}
|
||||
icon={[item.myState.hasLiked ? 'fas' : 'far', 'heart']}
|
||||
icon={[item.myState.like ? 'fas' : 'far', 'heart']}
|
||||
/>
|
||||
<Text
|
||||
style={item.myState.hasLiked ? [s.bold, s.red3] : undefined}>
|
||||
<Text style={item.myState.like ? [s.bold, s.red3] : undefined}>
|
||||
{item.likeCount}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
|
|
@ -26,7 +26,7 @@ export const Feed = observer(function Feed({feed}: {feed: FeedViewModel}) {
|
|||
{feed.isLoading && !feed.isRefreshing && !feed.hasContent && (
|
||||
<Text>Loading...</Text>
|
||||
)}
|
||||
{feed.hasError && <Text>{feed.error}</Text>}
|
||||
{feed.hasError && <Text>{feed.errorStr}</Text>}
|
||||
{feed.hasContent && (
|
||||
<FlatList
|
||||
data={feed.feed.slice()}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import React, {useMemo} from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {Image, StyleSheet, Text, TouchableOpacity, View} from 'react-native'
|
||||
import {bsky, AdxUri} from '@adxp/mock-api'
|
||||
import {AdxUri} from '../../../third-party/uri'
|
||||
import * as PostType from '../../../third-party/api/src/types/todo/social/post'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {FeedViewItemModel} from '../../../state/models/feed-view'
|
||||
import {ComposePostModel, SharePostModel} from '../../../state/models/shell'
|
||||
|
@ -18,7 +19,7 @@ export const FeedItem = observer(function FeedItem({
|
|||
item: FeedViewItemModel
|
||||
}) {
|
||||
const store = useStores()
|
||||
const record = item.record as unknown as bsky.Post.Record
|
||||
const record = item.record as unknown as PostType.Record
|
||||
const itemHref = useMemo(() => {
|
||||
const urip = new AdxUri(item.uri)
|
||||
return `/profile/${item.author.name}/post/${urip.recordKey}`
|
||||
|
@ -60,7 +61,7 @@ export const FeedItem = observer(function FeedItem({
|
|||
title={item.author.name}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.author.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.author.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</Link>
|
||||
<View style={styles.layoutContent}>
|
||||
|
@ -107,7 +108,7 @@ export const FeedItem = observer(function FeedItem({
|
|||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleRepost}>
|
||||
<FontAwesomeIcon
|
||||
style={
|
||||
item.myState.hasReposted
|
||||
item.myState.repost
|
||||
? styles.ctrlIconReposted
|
||||
: styles.ctrlIcon
|
||||
}
|
||||
|
@ -115,22 +116,19 @@ export const FeedItem = observer(function FeedItem({
|
|||
size={18}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
item.myState.hasReposted ? [s.bold, s.green3, s.f13] : s.f13
|
||||
}>
|
||||
style={item.myState.repost ? [s.bold, s.green3, s.f13] : s.f13}>
|
||||
{item.repostCount}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.ctrl} onPress={onPressToggleLike}>
|
||||
<FontAwesomeIcon
|
||||
style={
|
||||
item.myState.hasLiked ? styles.ctrlIconLiked : styles.ctrlIcon
|
||||
item.myState.like ? styles.ctrlIconLiked : styles.ctrlIcon
|
||||
}
|
||||
icon={[item.myState.hasLiked ? 'fas' : 'far', 'heart']}
|
||||
icon={[item.myState.like ? 'fas' : 'far', 'heart']}
|
||||
size={14}
|
||||
/>
|
||||
<Text
|
||||
style={item.myState.hasLiked ? [s.bold, s.red3, s.f13] : s.f13}>
|
||||
<Text style={item.myState.like ? [s.bold, s.red3, s.f13] : s.f13}>
|
||||
{item.likeCount}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
|
|
@ -83,7 +83,7 @@ const User = ({item}: {item: FollowerItem}) => {
|
|||
<View style={styles.layoutAvi}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.layoutContent}>
|
||||
|
|
|
@ -84,7 +84,7 @@ const User = ({item}: {item: FollowItem}) => {
|
|||
<View style={styles.layoutAvi}>
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[item.name] || AVIS['alice.com']}
|
||||
source={AVIS[item.name] || AVIS['alice.test']}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.layoutContent}>
|
||||
|
|
|
@ -81,7 +81,10 @@ export const ProfileHeader = observer(function ProfileHeader({
|
|||
return (
|
||||
<View style={styles.outer}>
|
||||
<Image style={styles.banner} source={BANNER} />
|
||||
<Image style={styles.avi} source={AVIS[view.name] || AVIS['alice.com']} />
|
||||
<Image
|
||||
style={styles.avi}
|
||||
source={AVIS[view.name] || AVIS['alice.test']}
|
||||
/>
|
||||
<View style={styles.content}>
|
||||
<View style={[styles.displayNameLine]}>
|
||||
<Text style={styles.displayName}>{view.displayName}</Text>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {ImageSourcePropType} from 'react-native'
|
||||
|
||||
export const AVIS: Record<string, ImageSourcePropType> = {
|
||||
'alice.com': require('../../../public/img/alice.jpg'),
|
||||
'bob.com': require('../../../public/img/bob.jpg'),
|
||||
'carla.com': require('../../../public/img/carla.jpg'),
|
||||
'alice.test': require('../../../public/img/alice.jpg'),
|
||||
'bob.test': require('../../../public/img/bob.jpg'),
|
||||
'carol.test': require('../../../public/img/carla.jpg'),
|
||||
}
|
||||
|
||||
export const BANNER: ImageSourcePropType = require('../../../public/img/banner.jpg')
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import {ImageSourcePropType} from 'react-native'
|
||||
|
||||
export const AVIS: Record<string, ImageSourcePropType> = {
|
||||
'alice.com': {uri: '/img/alice.jpg'},
|
||||
'bob.com': {uri: '/img/bob.jpg'},
|
||||
'carla.com': {uri: '/img/carla.jpg'},
|
||||
'alice.test': {uri: '/img/alice.jpg'},
|
||||
'bob.test': {uri: '/img/bob.jpg'},
|
||||
'carol.test': {uri: '/img/carla.jpg'},
|
||||
}
|
||||
|
||||
export const BANNER: ImageSourcePropType = {uri: '/img/banner.jpg'}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {AdxUri} from '@adxp/mock-api'
|
||||
import {AdxUri} from '../../third-party/uri'
|
||||
|
||||
export function pluralize(n: number, base: string, plural?: string): string {
|
||||
if (n === 1) {
|
||||
|
|
|
@ -80,7 +80,7 @@ export const Profile = observer(({visible, params}: ScreenParams) => {
|
|||
} else if (profileUiState.feed.hasError) {
|
||||
items.push({
|
||||
_reactKey: '__error__',
|
||||
error: profileUiState.feed.error,
|
||||
error: profileUiState.feed.errorStr,
|
||||
})
|
||||
renderItem = (item: any) => (
|
||||
<View style={s.p5}>
|
||||
|
|
|
@ -32,7 +32,7 @@ export function createAccountsMenu({
|
|||
<TouchableOpacity
|
||||
style={[styles.menuItem]}
|
||||
onPress={() => onPressItem(0)}>
|
||||
<Image style={styles.avi} source={AVIS['alice.com']} />
|
||||
<Image style={styles.avi} source={AVIS['alice.test']} />
|
||||
<Text style={[styles.label, s.bold]}>Alice</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
|
|
|
@ -113,7 +113,7 @@ export const MobileShell: React.FC = observer(() => {
|
|||
|
||||
const onPressAvi = () =>
|
||||
createAccountsMenu({
|
||||
debug_onPressItem: () => store.nav.navigate('/profile/alice.com'),
|
||||
debug_onPressItem: () => store.nav.navigate('/profile/alice.test'),
|
||||
})
|
||||
const onPressLocation = () => setLocationMenuActive(true)
|
||||
const onPressEllipsis = () => createLocationMenu()
|
||||
|
@ -168,7 +168,7 @@ export const MobileShell: React.FC = observer(() => {
|
|||
<View style={styles.outerContainer}>
|
||||
<View style={styles.topBar}>
|
||||
<TouchableOpacity onPress={onPressAvi}>
|
||||
<Image style={styles.avi} source={AVIS['alice.com']} />
|
||||
<Image style={styles.avi} source={AVIS['alice.test']} />
|
||||
</TouchableOpacity>
|
||||
<Location
|
||||
icon={screenRenderDesc.icon}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue