diff --git a/src/app/modules/admin/apps/mailbox/list/list.component.ts b/src/app/modules/admin/apps/mailbox/list/list.component.ts index 00b89ed2..938defb9 100644 --- a/src/app/modules/admin/apps/mailbox/list/list.component.ts +++ b/src/app/modules/admin/apps/mailbox/list/list.component.ts @@ -1,7 +1,6 @@ import { Component, ElementRef, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; -import * as moment from 'moment'; import { MailboxService } from 'app/modules/admin/apps/mailbox/mailbox.service'; import { MailboxComponent } from 'app/modules/admin/apps/mailbox/mailbox.component'; import { Mail, MailCategory } from 'app/modules/admin/apps/mailbox/mailbox.types'; @@ -119,77 +118,6 @@ export class MailboxListComponent implements OnInit, OnDestroy this._mailboxService.selectedMailChanged.next(mail); } - /** - * Generate and return mail list group label if necessary or return false - * - * @param index - */ - mailListGroupLabel(index: number): string | false - { - const previousMail = this.mails[index - 1]; - const currentMail = this.mails[index]; - - // Generate and return label, if there is no previous mail - if ( !previousMail ) - { - return this._generateMailListGroupLabel(this.mails[index].date); - } - - // Return false, if the two dates are equal by day - if ( moment(previousMail.date, moment.ISO_8601).isSame(moment(currentMail.date, moment.ISO_8601), 'day') ) - { - return false; - } - - // Generate and return label - return this._generateMailListGroupLabel(this.mails[index].date); - } - - // ----------------------------------------------------------------------------------------------------- - // @ Private methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Generate a mail list group label based on the date - * - * @param mailDate - * @private - */ - private _generateMailListGroupLabel(mailDate: string): string - { - const date = moment(mailDate, moment.ISO_8601); - const today = moment(); - const yesterday = moment().subtract(1, 'day'); - - // Check if the mail date is today - if ( date.isSame(today, 'day') ) - { - // Return 'Today' - return 'Today'; - } - - // Check if the mail date is yesterday - if ( date.isSame(yesterday, 'day') ) - { - // Return 'Yesterday' - return 'Yesterday'; - } - - // Check if we are in the same year with the mail date... - if ( date.isSame(today, 'year') ) - { - // Return a date without a year - return date.format('MMMM DD'); - } - - // Return a date - return date.format('LL'); - } - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - /** * Track by function for ngFor loops *