fedimbed: new limit fixes
This commit is contained in:
		
							parent
							
								
									a82fa92bed
								
							
						
					
					
						commit
						79041eee98
					
				
					 1 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
					@ -1456,15 +1456,25 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
  if (images.length > 0) {
 | 
					  if (images.length > 0) {
 | 
				
			||||||
 | 
					    const overMax = images.length + videos.length > 40;
 | 
				
			||||||
    if (images.length > 10) {
 | 
					    if (images.length > 10) {
 | 
				
			||||||
 | 
					      let i = 0;
 | 
				
			||||||
      while (images.length > 10) {
 | 
					      while (images.length > 10) {
 | 
				
			||||||
 | 
					        let max = 10;
 | 
				
			||||||
 | 
					        if (i == 3 && overMax) {
 | 
				
			||||||
 | 
					          if (videos.length > 0) max -= videos.length;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (i == 4) break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        container.components.push({
 | 
					        container.components.push({
 | 
				
			||||||
          type: 12,
 | 
					          type: 12,
 | 
				
			||||||
          items: images.splice(0, 10),
 | 
					          items: images.splice(0, max),
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					        i++;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // FIXME: guhhhhhh math
 | 
				
			||||||
    container.components.push({
 | 
					    container.components.push({
 | 
				
			||||||
      type: 12,
 | 
					      type: 12,
 | 
				
			||||||
      items: images,
 | 
					      items: images,
 | 
				
			||||||
| 
						 | 
					@ -1478,7 +1488,8 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (audios.length > 0) {
 | 
					  // FIXME: splitting if >5
 | 
				
			||||||
 | 
					  if (audios.length > 0 && audios.length < 6) {
 | 
				
			||||||
    container.components.push(
 | 
					    container.components.push(
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        type: 10,
 | 
					        type: 10,
 | 
				
			||||||
| 
						 | 
					@ -1512,11 +1523,7 @@ async function processUrl(msg, url, spoiler = false, command = false, inQuote =
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      quoteComponents.splice(0, 0, {type: 10, content: quoteContext});
 | 
					      quoteComponents.splice(0, 0, {type: 10, content: quoteContext});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (container.components.length + quoteComponents.length + 1 > 10) {
 | 
					    container.components.push({type: 14}, ...quoteComponents);
 | 
				
			||||||
      components.push(quoteComponents);
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      container.components.push({type: 14}, ...quoteComponents);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue