Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private getNoteSize(note: Note): Size {
- let attachmentsImage;
- if (note.attachments) {
- attachmentsImage = note.attachments.filter(
- (attachment: Attachment) => attachment.type === TypeAttachment.Image,
- );
- }
- let attachmentsSize = attachmentsImage && attachmentsImage.length;
- if (attachmentsSize > 4) {
- return Size.L;
- }
- if (note.type === TypeNote.List) {
- let noteList: NoteList = note;
- if (!noteList) {
- throw new Error('Wrong note type');
- }
- let noteListSize = noteList.items && noteList.items.length;
- if (noteListSize > 10) {
- return Size.L;
- }
- if (noteListSize > 5 || attachmentsSize > 2) {
- return Size.M;
- }
- return Size.S;
- }
- if (note.type === TypeNote.Text) {
- let noteText: NoteText = note;
- if (!noteText) {
- throw new Error('Wrong note type');
- }
- let noteTextSize = noteText.items && noteText.items.length;
- if (noteTextSize > 300) {
- return Size.L;
- }
- if (noteTextSize > 100 || attachmentsSize > 2) {
- return Size.M;
- }
- return Size.S;
- }
- if (note.type === TypeNote.Image) {
- return Size.M;
- }
- return Size.S;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement