| 
									
										
										
										
											2018-04-05 17:57:36 -07:00
										 |  |  | import pickBy from 'lodash-es/pickBy' | 
					
						
							| 
									
										
										
										
											2018-05-06 17:35:22 -07:00
										 |  |  | import get from 'lodash-es/get' | 
					
						
							| 
									
										
										
										
											2018-03-09 22:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 14:15:50 -08:00
										 |  |  | export function timelineMixins (Store) { | 
					
						
							| 
									
										
										
										
											2018-01-28 13:09:39 -08:00
										 |  |  |   Store.prototype.setForTimeline = function (instanceName, timelineName, obj) { | 
					
						
							| 
									
										
										
										
											2018-03-04 12:55:45 -08:00
										 |  |  |     let valuesToSet = {} | 
					
						
							|  |  |  |     for (let key of Object.keys(obj)) { | 
					
						
							|  |  |  |       let rootKey = `timelineData_${key}` | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:11 -07:00
										 |  |  |       let root = this.get()[rootKey] || {} | 
					
						
							| 
									
										
										
										
											2018-03-04 12:55:45 -08:00
										 |  |  |       let instanceData = root[instanceName] = root[instanceName] || {} | 
					
						
							|  |  |  |       instanceData[timelineName] = obj[key] | 
					
						
							|  |  |  |       valuesToSet[rootKey] = root | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     this.set(valuesToSet) | 
					
						
							| 
									
										
										
										
											2018-01-28 13:09:39 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Store.prototype.getForTimeline = function (instanceName, timelineName, key) { | 
					
						
							| 
									
										
										
										
											2018-03-04 12:55:45 -08:00
										 |  |  |     let rootKey = `timelineData_${key}` | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:11 -07:00
										 |  |  |     let root = this.get()[rootKey] | 
					
						
							| 
									
										
										
										
											2018-05-06 17:35:22 -07:00
										 |  |  |     return get(root, [instanceName, timelineName]) | 
					
						
							| 
									
										
										
										
											2018-01-28 13:09:39 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-02-10 13:57:04 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-21 00:53:52 -07:00
										 |  |  |   Store.prototype.getForCurrentTimeline = function (key) { | 
					
						
							| 
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 |  |  |     let { currentInstance, currentTimeline } = this.get() | 
					
						
							|  |  |  |     return this.getForTimeline(currentInstance, currentTimeline, key) | 
					
						
							| 
									
										
										
										
											2018-03-21 00:53:52 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-10 16:21:10 -08:00
										 |  |  |   Store.prototype.getAllTimelineData = function (instanceName, key) { | 
					
						
							| 
									
										
										
										
											2018-04-19 21:38:11 -07:00
										 |  |  |     let root = this.get()[`timelineData_${key}`] || {} | 
					
						
							| 
									
										
										
										
											2018-03-10 16:21:10 -08:00
										 |  |  |     return root[instanceName] || {} | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-10 13:57:04 -08:00
										 |  |  |   Store.prototype.setForCurrentTimeline = function (obj) { | 
					
						
							| 
									
										
										
										
											2018-04-19 09:37:05 -07:00
										 |  |  |     let { currentInstance, currentTimeline } = this.get() | 
					
						
							|  |  |  |     this.setForTimeline(currentInstance, currentTimeline, obj) | 
					
						
							| 
									
										
										
										
											2018-02-10 13:57:04 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-03-09 22:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-10 16:21:10 -08:00
										 |  |  |   Store.prototype.getThreads = function (instanceName) { | 
					
						
							|  |  |  |     let instanceData = this.getAllTimelineData(instanceName, 'timelineItemIds') | 
					
						
							| 
									
										
										
										
											2018-03-09 22:31:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return pickBy(instanceData, (value, key) => { | 
					
						
							|  |  |  |       return key.startsWith('status/') | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-01-28 13:09:39 -08:00
										 |  |  | } |