refactor(ApNoteService.ts): note.attachment
				
					
				
			- `toArray()`を使うように - よくわからない条件式を整理 - `as`をなくすために`promiseLimit()`でジェネリクスを使うように
This commit is contained in:
		@@ -170,14 +170,11 @@ export class ApNoteService {
 | 
				
			|||||||
		// TODO: attachmentは必ずしもImageではない
 | 
							// TODO: attachmentは必ずしもImageではない
 | 
				
			||||||
		// TODO: attachmentは必ずしも配列ではない
 | 
							// TODO: attachmentは必ずしも配列ではない
 | 
				
			||||||
		// Noteがsensitiveなら添付もsensitiveにする
 | 
							// Noteがsensitiveなら添付もsensitiveにする
 | 
				
			||||||
		const limit = promiseLimit(2);
 | 
							const limit = promiseLimit<DriveFile>(2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		note.attachment = Array.isArray(note.attachment) ? note.attachment : note.attachment ? [note.attachment] : [];
 | 
							note.attachment = toArray(note.attachment);
 | 
				
			||||||
		const files = note.attachment
 | 
							note.attachment.forEach(attach => attach.sensitive = note.sensitive);
 | 
				
			||||||
			.map(attach => attach.sensitive = note.sensitive)
 | 
							const files = (await Promise.all(note.attachment.map(x => limit(() => this.apImageService.resolveImage(actor, x)))));
 | 
				
			||||||
			? (await Promise.all(note.attachment.map(x => limit(() => this.apImageService.resolveImage(actor, x)) as Promise<DriveFile>)))
 | 
					 | 
				
			||||||
				.filter(image => image != null)
 | 
					 | 
				
			||||||
			: [];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// リプライ
 | 
							// リプライ
 | 
				
			||||||
		const reply: Note | null = note.inReplyTo
 | 
							const reply: Note | null = note.inReplyTo
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user