@@ -12,19 +12,13 @@ const ThreadItem = (props) => {
12
12
const onList = async ( options ?: Record < string , any > ) => {
13
13
const listing = await Queries . onUserListThreadReplies ( { id : props . threadId , key : null , orderBy : { column : 'created_at' , value : 'desc' } } ) ;
14
14
if ( ! listing || listing . error ) {
15
- props . setModal ( {
16
- name : 'ERROR' ,
17
- message : 'Something went wrong with listing replies to this post.' ,
18
- } ) ;
15
+ props . onError ( 'Something went wrong with listing replies to this post.' ) ;
19
16
return ;
20
17
}
21
18
22
19
if ( options && options . checkEmptyArrayError ) {
23
20
if ( ! listing . data . length ) {
24
- props . setModal ( {
25
- name : 'ERROR' ,
26
- message : 'There are no replies to this thread, make one!' ,
27
- } ) ;
21
+ props . onError ( 'There are no replies to this thread, make one!' ) ;
28
22
return ;
29
23
}
30
24
}
@@ -34,20 +28,14 @@ const ThreadItem = (props) => {
34
28
35
29
const onReply = async ( ) => {
36
30
if ( ! props . viewer ) {
37
- props . setModal ( {
38
- name : 'ERROR' ,
39
- message : 'You need to sign in first.' ,
40
- } ) ;
31
+ props . onError ( 'You need to sign in first.' ) ;
41
32
return ;
42
33
}
43
34
44
35
const plainText = window . prompt ( 'The easiest way to do this without building the modal. Type what words you want to share.' ) ;
45
36
46
37
if ( Utilities . isEmpty ( plainText ) ) {
47
- props . setModal ( {
48
- name : 'ERROR' ,
49
- message : 'You must provide words.' ,
50
- } ) ;
38
+ props . onError ( 'You must provide words.' ) ;
51
39
return ;
52
40
}
53
41
@@ -62,19 +50,13 @@ const ThreadItem = (props) => {
62
50
type : 'GENERAL' ,
63
51
} ) ;
64
52
if ( ! response ) {
65
- props . setModal ( {
66
- name : 'ERROR' ,
67
- message : 'Something went wrong with creating creating a thread' ,
68
- } ) ;
53
+ props . onError ( 'Something went wrong with creating creating a thread' ) ;
69
54
return ;
70
55
}
71
56
72
57
const listing = await Queries . onUserListThreadReplies ( { id : props . threadId , key : null , orderBy : { column : 'created_at' , value : 'desc' } } ) ;
73
58
if ( ! listing ) {
74
- props . setModal ( {
75
- name : 'ERROR' ,
76
- message : 'Something went wrong with listing threads' ,
77
- } ) ;
59
+ props . onError ( 'Something went wrong with listing threads' ) ;
78
60
return ;
79
61
}
80
62
@@ -124,7 +106,7 @@ const ThreadItem = (props) => {
124
106
isLast = { index === list . length - 1 }
125
107
key = { each . id }
126
108
sessionKey = { props . sessionKey }
127
- setModal = { props . setModal }
109
+ onError = { props . onError }
128
110
threadId = { each . id }
129
111
viewer = { props . viewer }
130
112
>
@@ -152,7 +134,7 @@ export default function DemoThreads(props) {
152
134
{ props . data . map ( ( each , index ) => {
153
135
const author = props . viewer && props . viewer . id === each . user_id ? `You` : `Anonymous` ;
154
136
return (
155
- < ThreadItem isLast = { index === props . data . length - 1 } key = { each . id } sessionKey = { props . sessionKey } setModal = { props . setModal } threadId = { each . id } viewer = { props . viewer } >
137
+ < ThreadItem isLast = { index === props . data . length - 1 } key = { each . id } sessionKey = { props . sessionKey } onError = { props . onError } threadId = { each . id } viewer = { props . viewer } >
156
138
< div className = { styles . byline } >
157
139
{ author } ⎯ { Utilities . timeAgo ( each . created_at ) }
158
140
</ div >
0 commit comments