Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/app/start/sender-hilights.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
.subject li {
list-style-type: square;
}
.emailDate {
color: rgba(0, 0, 0, 0.54);
display: inline-block;
font-size: 0.75em;
margin-right: 0.5em;
white-space: nowrap;
}
.subject a {
text-decoration: none !important;
}
Expand Down
85 changes: 85 additions & 0 deletions src/app/start/sender-hilights.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// --------- BEGIN RUNBOX LICENSE ---------
// Copyright (C) 2016-2026 Runbox Solutions AS (runbox.com).
//
// This file is part of Runbox 7.
//
// Runbox 7 is free software: You can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// Runbox 7 is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Runbox 7. If not, see <https://www.gnu.org/licenses/>.
// ---------- END RUNBOX LICENSE ----------

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatLegacyButtonModule as MatButtonModule } from '@angular/material/legacy-button';
import { MatLegacyCardModule as MatCardModule } from '@angular/material/legacy-card';
import { MatIconModule } from '@angular/material/icon';
import { RouterTestingModule } from '@angular/router/testing';

import { SearchIndexDocumentData } from '../xapian/searchservice';
import { SenderHilightsComponent } from './sender-hilights.component';

describe('SenderHilightsComponent', () => {
let component: SenderHilightsComponent;
let fixture: ComponentFixture<SenderHilightsComponent>;

const message = (date?: string): SearchIndexDocumentData => ({
id: 'M123',
date,
folder: 'Inbox',
from: 'sender@example.com',
subject: 'Quarterly report',
recipients: ['me@example.com'],
textcontent: '',
});

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [SenderHilightsComponent],
imports: [
MatButtonModule,
MatCardModule,
MatIconModule,
RouterTestingModule,
],
}).compileComponents();

fixture = TestBed.createComponent(SenderHilightsComponent);
component = fixture.componentInstance;
});

it('shows message dates before subjects when overview messages have indexed dates', () => {
component.sender = {
icon: 'person',
name: 'Sender',
emails: [message('202001020304')],
};
component.ngOnChanges();

fixture.detectChanges();

const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.emailDate').textContent.trim()).toBe('2020-01-02');
expect(compiled.textContent).toContain('Quarterly report');
});

it('omits the message date when the overview message has no indexed date', () => {
component.sender = {
icon: 'person',
name: 'Sender',
emails: [message()],
};
component.ngOnChanges();

fixture.detectChanges();

expect((fixture.nativeElement as HTMLElement).querySelector('.emailDate')).toBeNull();
});
});
9 changes: 9 additions & 0 deletions src/app/start/sender-hilights.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { Component, ChangeDetectionStrategy, Input, OnChanges, Output, EventEmitter } from '@angular/core';

import { MessageTableRowTool } from '../messagetable/messagetablerow';
import { SearchIndexDocumentData } from '../xapian/searchservice';
import { ContactHilights } from './startdesk.component';

Expand All @@ -34,6 +35,7 @@ import { ContactHilights } from './startdesk.component';
<div class="subject">
<ul>
<li *ngFor="let email of shownEmails">
<span class="emailDate" *ngIf="messageDate(email) as date">{{ date }}</span>
<a routerLink="/" [fragment]="emailPath(email)"> {{ email.subject }} </a>
</li>
</ul>
Expand Down Expand Up @@ -76,4 +78,11 @@ export class SenderHilightsComponent implements OnChanges {
const id = email.id.slice(1);
return `${folderPath}:${id}`;
}

public messageDate(email: SearchIndexDocumentData): string {
if (!email.date) {
return '';
}
return MessageTableRowTool.formatTimestampFromStringWithoutSeparators(email.date);
}
}
2 changes: 2 additions & 0 deletions src/app/xapian/searchservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const XAPIAN_GLASS_WR = 'xapianglasswr';
// FIXME: Also in index.worker.ts
export class SearchIndexDocumentData {
id: string;
date?: string;
from: string;
subject: string;
recipients: string[];
Expand Down Expand Up @@ -851,6 +852,7 @@ export class SearchService {

this.currentDocData = {
id: docdataparts[0],
date: this.api.getStringValue(docid, 2),
from: docdataparts[1],
subject: docdataparts[2],
recipients: [],
Expand Down