| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  | <div class="status-article-compose-box"> | 
					
						
							| 
									
										
										
										
											2018-05-01 17:05:36 -07:00
										 |  |  |   <ComposeBox realm={originalStatusId} | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |               size="slim" | 
					
						
							|  |  |  |               autoFocus="true" | 
					
						
							|  |  |  |               hideBottomBorder="true" | 
					
						
							| 
									
										
										
										
											2018-04-04 23:03:26 -07:00
										 |  |  |               isReply="true" | 
					
						
							| 
									
										
										
										
											2018-05-01 17:05:36 -07:00
										 |  |  |               replyVisibility={visibility} | 
					
						
							|  |  |  |               replySpoiler={spoilerText} | 
					
						
							|  |  |  |               inReplyToUuid={uuid} | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |   /> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | <style> | 
					
						
							|  |  |  |   .status-article-compose-box { | 
					
						
							|  |  |  |     grid-area: compose; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | </style> | 
					
						
							|  |  |  | <script> | 
					
						
							|  |  |  |   import ComposeBox from '../../_components/compose/ComposeBox.html' | 
					
						
							|  |  |  |   import { store } from '../../_store/store' | 
					
						
							| 
									
										
										
										
											2018-04-05 17:57:36 -07:00
										 |  |  |   import debounce from 'lodash-es/debounce' | 
					
						
							|  |  |  |   import throttle from 'lodash-es/throttle' | 
					
						
							| 
									
										
										
										
											2018-04-08 15:08:32 -07:00
										 |  |  |   import { on } from '../../_utils/eventBus' | 
					
						
							| 
									
										
										
										
											2018-04-30 08:29:04 -07:00
										 |  |  |   import { observe } from 'svelte-extras' | 
					
						
							| 
									
										
										
										
											2018-03-30 08:43:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const DEBOUNCE_DELAY = 400 | 
					
						
							|  |  |  |   const THROTTLE_DELAY = 150 | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   export default { | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:01 -07:00
										 |  |  |     oncreate () { | 
					
						
							| 
									
										
										
										
											2018-04-08 15:08:32 -07:00
										 |  |  |       on('postedStatus', this, this.onPostedStatus) | 
					
						
							|  |  |  |       this.setupRecalculateHeightListener() | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |     }, | 
					
						
							|  |  |  |     store: () => store, | 
					
						
							|  |  |  |     computed: { | 
					
						
							| 
									
										
										
										
											2018-05-01 17:05:36 -07:00
										 |  |  |       composeData: ({ $currentComposeData, originalStatusId }) => $currentComposeData[originalStatusId] || {} | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |     }, | 
					
						
							|  |  |  |     methods: { | 
					
						
							| 
									
										
										
										
											2018-04-30 08:29:04 -07:00
										 |  |  |       observe, | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:01 -07:00
										 |  |  |       onPostedStatus (realm) { | 
					
						
							| 
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 |  |  |         let { originalStatusId } = this.get() | 
					
						
							|  |  |  |         if (realm !== originalStatusId) { | 
					
						
							| 
									
										
										
										
											2018-04-08 15:08:32 -07:00
										 |  |  |           return | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |         requestAnimationFrame(() => { | 
					
						
							| 
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 |  |  |           let { uuid } = this.get() | 
					
						
							|  |  |  |           let { repliesShown } = this.store.get() | 
					
						
							|  |  |  |           repliesShown[uuid] = false | 
					
						
							|  |  |  |           this.store.set({repliesShown}) | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |           this.fire('recalculateHeight') | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2018-04-08 15:08:32 -07:00
										 |  |  |       }, | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:01 -07:00
										 |  |  |       setupRecalculateHeightListener () { | 
					
						
							| 
									
										
										
										
											2018-04-08 15:08:32 -07:00
										 |  |  |         const recalc = () => requestAnimationFrame(() => this.fire('recalculateHeight')) | 
					
						
							|  |  |  |         // debounce AND throttle due to 333ms content warning animation | 
					
						
							|  |  |  |         const debounced = debounce(recalc, DEBOUNCE_DELAY) | 
					
						
							|  |  |  |         const throttled = throttle(() => { | 
					
						
							|  |  |  |           debounced() | 
					
						
							|  |  |  |           recalc() | 
					
						
							|  |  |  |         }, THROTTLE_DELAY, { | 
					
						
							|  |  |  |           leading: true, | 
					
						
							|  |  |  |           trailing: true | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         this.observe('composeData', throttled) | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2018-04-08 15:08:32 -07:00
										 |  |  |     }, | 
					
						
							|  |  |  |     components: { | 
					
						
							|  |  |  |       ComposeBox | 
					
						
							| 
									
										
										
										
											2018-03-30 01:06:17 -07:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | </script> |