1
1
import { sendForm } from "./api" ;
2
- import { borderbox , col , flex , gap , h100 , scrolly , w100 , wevenly } from "./css" ;
2
+ import { borderbox , col , flex , gap , h100 , hcenter , scrolly , w100 , wevenly } from "./css" ;
3
3
import { Container } from "./Container" ;
4
+ import { KnownStatus } from "./state" ;
4
5
5
- let style = css `
6
+ const Visibility = {
7
+ direct : 0 ,
8
+ private : 1 ,
9
+ local : 2 ,
10
+ unlisted : 3 ,
11
+ public : 4
12
+ } as const ;
6
13
14
+ let grayed = rule `background-color : blue ` ;
15
+ export const Compose : Component < {
16
+ replyto ?: KnownStatus
17
+ content ?: string
18
+ // gahd damn liberals
19
+ cw ?: string
20
+ onsend ?: ( ) => void
21
+ } , {
22
+ files : ComponentElement < typeof FileView > [ ]
23
+ inputelm : HTMLElement
24
+ sending : boolean
25
+ visibility : keyof typeof Visibility
26
+ } > = function ( ) {
27
+ this . css = css `
7
28
self {
8
29
gap : 0.5em ;
9
30
}
@@ -17,20 +38,14 @@ button {
17
38
border : none;
18
39
background-color : var (--accent );
19
40
}
20
- ` ;
21
41
22
- let grayed = rule `background-color : blue` ;
23
- export const Compose : Component < {
24
- content ?: string
25
- // gahd damn liberals
26
- cw ?: string
27
- onsend ?: ( ) => void
28
- } , {
29
- files : ComponentElement < typeof FileView > [ ]
30
- inputelm : HTMLElement
31
- sending : boolean
32
- } > = function ( ) {
33
- this . css = style ;
42
+ .visibility {
43
+ .active {
44
+ color : var (--accent );
45
+ }
46
+ }
47
+ ` ;
48
+ this . visibility = this . replyto ?. object . visibility || "public" ;
34
49
35
50
this . files = [ ] ;
36
51
this . content ??= "" ;
@@ -57,21 +72,43 @@ export const Compose: Component<{
57
72
</ div >
58
73
) }
59
74
60
- < div class = { [ flex , w100 ] } >
61
- < div >
62
- visibility
75
+ < div class = { [ flex , hcenter , w100 , gap ] } >
76
+ < div class = { [ flex , hcenter , gap , "visibility" ] } >
77
+ < iconify-icon class = { [ use ( this . visibility , ( v : any ) => v == "direct" && "active" ) ] } on :click = { ( ) => this . visibility = "direct" } icon = "fa:envelope" />
78
+ {
79
+ ! this . replyto || Visibility [ this . replyto . object . visibility ] > Visibility . direct ?
80
+ < >
81
+ < iconify-icon class = { [ use ( this . visibility , ( v : any ) => v == "private" && "active" ) ] } on :click = { ( ) => this . visibility = "private" } icon = "fa:lock" />
82
+ {
83
+ ! this . replyto || Visibility [ this . replyto . object . visibility ] > Visibility . private ?
84
+ < >
85
+ < iconify-icon class = { [ use ( this . visibility , ( v : any ) => v == "unlisted" && "active" ) ] } on :click = { ( ) => this . visibility = "unlisted" } icon = "fa-solid:lock-open" />
86
+ {
87
+ ! this . replyto || Visibility [ this . replyto . object . visibility ] > Visibility . unlisted ?
88
+ < iconify-icon class = { [ use ( this . visibility , ( v : any ) => v == "public" && "active" ) ] } on :click = { ( ) => this . visibility = "public" } icon = "fa:globe" />
89
+ : ""
90
+ }
91
+ </ >
92
+ : ""
93
+ }
94
+ </ >
95
+ : ""
96
+ }
63
97
</ div >
64
98
< button class = { [ grayed ] } on :click = { async ( ) => {
65
99
this . sending = true ;
66
100
$el . classList . toggle ( grayed ) ;
67
101
try {
68
- await sendForm ( "/api/v1/statuses" , {
102
+ let payload : any = {
69
103
status : this . content ! ,
70
104
source : "Pleroma for Nintendo DS" ,
71
- visibility : "direct" ,
105
+ visibility : this . visibility ,
72
106
content_type : "text/plain" ,
73
107
language : "en" //rahhhhh
74
- } ) ;
108
+ } ;
109
+ if ( this . replyto )
110
+ payload . in_reply_to_id = this . replyto . id ;
111
+ await sendForm ( "/api/v1/statuses" , payload ) ;
75
112
} catch { }
76
113
$el . classList . toggle ( grayed ) ;
77
114
this . sending = false ;
0 commit comments