mirror of
https://github.com/sigmasternchen/threadule
synced 2025-03-15 08:09:01 +00:00
feat: set ordinal for tweets correctly
(maybe do this in backend instead #improvement)
This commit is contained in:
parent
046a9fb12a
commit
ea4845161c
3 changed files with 21 additions and 3 deletions
|
@ -13,6 +13,10 @@ class ThreadEndpoint extends Endpoint {
|
|||
public async add(thread: Thread): Promise<Thread> {
|
||||
return await this.post<Thread, Thread>(API_PREFIX, thread)
|
||||
}
|
||||
|
||||
public async update(thread: Thread): Promise<Thread> {
|
||||
return await this.put<Thread, Thread>(API_PREFIX + thread.id, thread)
|
||||
}
|
||||
}
|
||||
|
||||
export default ThreadEndpoint
|
|
@ -29,6 +29,7 @@ const emptyThread = (account: Account): Thread => ({
|
|||
status: TweetStatus.SCHEDULED,
|
||||
tweet_id: null,
|
||||
error: null,
|
||||
ordinal: 0,
|
||||
}
|
||||
],
|
||||
error: null,
|
||||
|
@ -47,6 +48,9 @@ const AccountCard: FunctionComponent<AccountCardProps> = (
|
|||
const openNewForm = () => {
|
||||
setEditThread(emptyThread(account))
|
||||
}
|
||||
const openEditForm = (thread: Thread) => {
|
||||
setEditThread(thread)
|
||||
}
|
||||
|
||||
const [message, setMessage] = useState<MessageBoxProps>({
|
||||
open: false,
|
||||
|
@ -75,7 +79,10 @@ const AccountCard: FunctionComponent<AccountCardProps> = (
|
|||
subheader={account.screen_name}
|
||||
/>
|
||||
<CardContent>
|
||||
<ThreadList threads={account.threads}/>
|
||||
<ThreadList
|
||||
threads={account.threads}
|
||||
onSelect={openEditForm}
|
||||
/>
|
||||
</CardContent>
|
||||
<CardActions disableSpacing>
|
||||
<IconButton aria-label="add" onClick={() => {
|
||||
|
|
|
@ -7,9 +7,10 @@ import styles from "./ThreadList.module.css"
|
|||
|
||||
export type ThreadListProps = {
|
||||
threads: Thread[]
|
||||
onSelect: (thread: Thread) => void
|
||||
}
|
||||
|
||||
const ThreadList: FunctionComponent<ThreadListProps> = ({threads}) => {
|
||||
const ThreadList: FunctionComponent<ThreadListProps> = ({threads, onSelect}) => {
|
||||
if (threads.length == 0) {
|
||||
return (
|
||||
<Typography style={{
|
||||
|
@ -23,7 +24,13 @@ const ThreadList: FunctionComponent<ThreadListProps> = ({threads}) => {
|
|||
<List>
|
||||
{threads.map(thread => {
|
||||
return (
|
||||
<ListItem key={thread.id}>
|
||||
<ListItem
|
||||
button
|
||||
key={thread.id}
|
||||
onClick={() => {
|
||||
onSelect(thread)
|
||||
}}
|
||||
>
|
||||
<ListItemAvatar>
|
||||
<Avatar>
|
||||
{thread.tweets.length}
|
||||
|
|
Loading…
Reference in a new issue