added visibility function to compose box + reply ID
This commit is contained in:
		
							parent
							
								
									49409bac68
								
							
						
					
					
						commit
						e74b088e37
					
				
					 3 changed files with 60 additions and 17 deletions
				
			
		|  | @ -76,7 +76,7 @@ main { | ||||||
| 
 | 
 | ||||||
| img.emoji { | img.emoji { | ||||||
|     height: 1.2em; |     height: 1.2em; | ||||||
|     margin: -.1em 0; |     margin: -.2em 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .throb { | .throb { | ||||||
|  | @ -90,4 +90,4 @@ img.emoji { | ||||||
|     to { |     to { | ||||||
|         opacity: 1; |         opacity: 1; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -14,11 +14,18 @@ | ||||||
|     import WarningIcon from '@cf/icons/warning.svg'; |     import WarningIcon from '@cf/icons/warning.svg'; | ||||||
| 
 | 
 | ||||||
|     import PublicVisIcon from '@cf/icons/public.svg'; |     import PublicVisIcon from '@cf/icons/public.svg'; | ||||||
|  |     import UnlistedVisIcon from '@cf/icons/unlisted.svg'; | ||||||
|  |     import FollowersVisIcon from '@cf/icons/followers.svg'; | ||||||
|  |     import PrivateVisIcon from '@cf/icons/dm.svg'; | ||||||
|  | 
 | ||||||
|  |     export let reply_id; | ||||||
| 
 | 
 | ||||||
|     let content_warning = "" |     let content_warning = "" | ||||||
|     let content = ""; |     let content = ""; | ||||||
|     // let media_ids = []; |     // let media_ids = []; | ||||||
|     let show_cw = false; |     let show_cw = false; | ||||||
|  |     let visibility = "Public"; | ||||||
|  | 
 | ||||||
|     const placeholders = [ |     const placeholders = [ | ||||||
|         "What's cooking, $1?", |         "What's cooking, $1?", | ||||||
|         "Speak your mind!", |         "Speak your mind!", | ||||||
|  | @ -33,12 +40,28 @@ | ||||||
| 
 | 
 | ||||||
|     async function buildPost() { |     async function buildPost() { | ||||||
|         let postdata = {} |         let postdata = {} | ||||||
|         if(show_cw) { |  | ||||||
|             postdata.spoiler_text = content_warning; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if(!content) return; |         if (!content) return; | ||||||
|         postdata.status = content; |         postdata.status = content; | ||||||
|  |         switch (visibility) { | ||||||
|  |             case "Public": | ||||||
|  |                 postdata.visibility = "public"; | ||||||
|  |                 break; | ||||||
|  |             case "Unlisted": | ||||||
|  |                 postdata.visibility = "unlisted"; | ||||||
|  |                 break; | ||||||
|  |             case "Followers only": | ||||||
|  |                 postdata.visibility = "private"; | ||||||
|  |                 break; | ||||||
|  |             case "Private": | ||||||
|  |                 postdata.visibility = "direct"; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |         if (show_cw) { | ||||||
|  |             postdata.spoiler_text = content_warning; | ||||||
|  |             postdata.sensitive = true; | ||||||
|  |         } | ||||||
|  |         if (reply_id) postdata.in_reply_to_id = reply_id; | ||||||
| 
 | 
 | ||||||
|         let new_post = await api.createPost($server.host, $app.token, postdata); |         let new_post = await api.createPost($server.host, $app.token, postdata); | ||||||
|         let new_post_parsed = await parsePost(new_post); |         let new_post_parsed = await parsePost(new_post); | ||||||
|  | @ -46,6 +69,23 @@ | ||||||
|         timeline.update(current => [new_post_parsed, ...current]); |         timeline.update(current => [new_post_parsed, ...current]); | ||||||
|         dispatch("compose_finished") |         dispatch("compose_finished") | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     function cycleVisibility() { | ||||||
|  |         switch (visibility) { | ||||||
|  |             case "Public": | ||||||
|  |                 visibility = "Unlisted"; | ||||||
|  |                 break; | ||||||
|  |             case "Unlisted": | ||||||
|  |                 visibility = "Followers only"; | ||||||
|  |                 break; | ||||||
|  |             case "Followers only": | ||||||
|  |                 visibility = "Private"; | ||||||
|  |                 break; | ||||||
|  |             case "Private": | ||||||
|  |                 visibility = "Public"; | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <div class="composer"> | <div class="composer"> | ||||||
|  | @ -55,22 +95,31 @@ | ||||||
|         </a> |         </a> | ||||||
|         <header class="composer-header"> |         <header class="composer-header"> | ||||||
|             <div class="composer-user-info" on:mouseup|stopPropagation> |             <div class="composer-user-info" on:mouseup|stopPropagation> | ||||||
|                 {@html $account.rich_name} |                 <span class="display-name">{@html $account.rich_name}</span> | ||||||
|                 <span class="username">{$account.mention}</span> |                 <span class="username">{$account.mention}</span> | ||||||
|             </div> |             </div> | ||||||
|             <div class="composer-info" on:mouseup|stopPropagation> |             <div class="composer-info" on:mouseup|stopPropagation> | ||||||
|             </div> |             </div> | ||||||
|         </header> |         </header> | ||||||
|         <div> |         <div title={visibility}> | ||||||
|             <Button centered={true}> |             <Button centered={true} on:click={() => {cycleVisibility()}}> | ||||||
|                 <svelte:fragment slot="icon"> |                 <svelte:fragment slot="icon"> | ||||||
|                     <PublicVisIcon/> |                     <!-- TODO: this should be a drop-down option!...later --> | ||||||
|  |                     {#if visibility === "Public"} | ||||||
|  |                         <PublicVisIcon/> | ||||||
|  |                     {:else if visibility === "Unlisted"} | ||||||
|  |                         <UnlistedVisIcon/> | ||||||
|  |                     {:else if visibility === "Followers only"} | ||||||
|  |                         <FollowersVisIcon/> | ||||||
|  |                     {:else if visibility === "Private"} | ||||||
|  |                         <PrivateVisIcon/> | ||||||
|  |                     {/if} | ||||||
|                 </svelte:fragment> |                 </svelte:fragment> | ||||||
|             </Button> |             </Button> | ||||||
|         </div> |         </div> | ||||||
|     </div> |     </div> | ||||||
|     {#if show_cw} |     {#if show_cw} | ||||||
|         <input type="text" id="" placeholder="content warning" bind:value={content_warning}/> |         <input type="text" id="" placeholder="Content warning" bind:value={content_warning}/> | ||||||
|     {/if} |     {/if} | ||||||
|     <textarea placeholder="{placeholder}" class="textbox" bind:value={content}></textarea> |     <textarea placeholder="{placeholder}" class="textbox" bind:value={content}></textarea> | ||||||
|     <div class="composer-footer"> |     <div class="composer-footer"> | ||||||
|  |  | ||||||
|  | @ -79,12 +79,6 @@ | ||||||
|         display: block; |         display: block; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     .post-user-info .name :global(.emoji) { |  | ||||||
|         position: relative; |  | ||||||
|         top: .2em; |  | ||||||
|         height: 1.2em; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     .post-user-info .username { |     .post-user-info .username { | ||||||
|         opacity: .8; |         opacity: .8; | ||||||
|         font-size: .9em; |         font-size: .9em; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue