kopia lustrzana https://gitlab.com/mysocialportal/relatica
				
				
				
			Fix full context post/comment pull where newer items have lower IDs (no idea how)
							rodzic
							
								
									7a41065a1c
								
							
						
					
					
						commit
						5328d9d170
					
				|  | @ -252,25 +252,45 @@ class EntryManagerService extends ChangeNotifier { | |||
|       }); | ||||
|     } | ||||
| 
 | ||||
|     allSeenItems.sort((i1, i2) => int.parse(i1.id).compareTo(int.parse(i2.id))); | ||||
|     allSeenItems.sort((i1, i2) { | ||||
|       if (i1.parentId.isEmpty && i2.parentId.isNotEmpty) { | ||||
|         return -1; | ||||
|       } | ||||
| 
 | ||||
|       if (i2.parentId.isEmpty && i1.parentId.isNotEmpty) { | ||||
|         return 1; | ||||
|       } | ||||
| 
 | ||||
|       return int.parse(i1.id).compareTo(int.parse(i2.id)); | ||||
|     }); | ||||
|     final postNodesToReturn = <_Node>{}; | ||||
|     for (final item in allSeenItems) { | ||||
|       if (item.parentId.isEmpty) { | ||||
|         final postNode = _postNodes.putIfAbsent(item.id, () => _Node(item.id)); | ||||
|         postNodesToReturn.add(postNode); | ||||
|       } else { | ||||
|         final parentParentPostId = _postNodes.containsKey(item.parentId) | ||||
|             ? item.parentId | ||||
|             : _parentPostIds[item.parentId]; | ||||
|         final parentPostNode = _postNodes[parentParentPostId]!; | ||||
|         postNodesToReturn.add(parentPostNode); | ||||
|         _parentPostIds[item.id] = parentPostNode.id; | ||||
|         if (parentPostNode.getChildById(item.id) == null) { | ||||
|           final newNode = _Node(item.id); | ||||
|           final injectionNode = parentPostNode.id == item.parentId | ||||
|               ? parentPostNode | ||||
|               : parentPostNode.getChildById(item.parentId)!; | ||||
|           injectionNode.addChild(newNode); | ||||
|     while (allSeenItems.isNotEmpty) { | ||||
|       final seenItemsCopy = [...allSeenItems]; | ||||
|       for (final item in seenItemsCopy) { | ||||
|         if (item.parentId.isEmpty) { | ||||
|           final postNode = | ||||
|               _postNodes.putIfAbsent(item.id, () => _Node(item.id)); | ||||
|           postNodesToReturn.add(postNode); | ||||
|           allSeenItems.remove(item); | ||||
|         } else { | ||||
|           final parentParentPostId = _postNodes.containsKey(item.parentId) | ||||
|               ? item.parentId | ||||
|               : _parentPostIds[item.parentId]; | ||||
|           final parentPostNode = _postNodes[parentParentPostId]!; | ||||
|           postNodesToReturn.add(parentPostNode); | ||||
|           _parentPostIds[item.id] = parentPostNode.id; | ||||
|           if (parentPostNode.getChildById(item.id) == null) { | ||||
|             final newNode = _Node(item.id); | ||||
|             final injectionNode = parentPostNode.id == item.parentId | ||||
|                 ? parentPostNode | ||||
|                 : parentPostNode.getChildById(item.parentId); | ||||
|             if (injectionNode == null) { | ||||
|               continue; | ||||
|             } else { | ||||
|               injectionNode.addChild(newNode); | ||||
|               allSeenItems.remove(item); | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Hank Grabowski
						Hank Grabowski