2018-02-11 10:35:25 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import { store } from '../_store/store'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import { cacheFirstUpdateAfter } from '../_utils/sync'
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-16 20:56:21 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  getPinnedStatuses as getPinnedStatusesFromDatabase,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  insertPinnedStatuses as insertPinnedStatusesInDatabase
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								} from '../_database/timelines/pinnedStatuses'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  getPinnedStatuses
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								} from '../_api/pinnedStatuses'
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-11 10:35:25 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-11 14:11:03 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								export async function updatePinnedStatusesForAccount (accountId) {
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  let { currentInstance, accessToken } = store.get()
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-11 10:35:25 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await cacheFirstUpdateAfter(
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    () => getPinnedStatuses(currentInstance, accessToken, accountId),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    () => getPinnedStatusesFromDatabase(currentInstance, accountId),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    statuses => insertPinnedStatusesInDatabase(currentInstance, accountId, statuses),
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-11 10:35:25 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    statuses => {
							 | 
						
					
						
							
								
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      let { pinnedStatuses } = store.get()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      pinnedStatuses[currentInstance] = pinnedStatuses[currentInstance] || {}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      pinnedStatuses[currentInstance][accountId] = statuses
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      store.set({pinnedStatuses: pinnedStatuses})
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-11 10:35:25 -08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  )
							 | 
						
					
						
							
								
									
										
										
										
											2018-02-11 14:11:03 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								}
							 |