Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
atifsaddique211f committed Apr 5, 2019
2 parents a124ac3 + b351553 commit e6e0541
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 44 deletions.
4 changes: 2 additions & 2 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Official Angular cross-platform client for the CTemplar secure email service available at [https://ctemplar.com](https://ctemplar.com).

RELEASE VERSION : **v1.1.28**
RELEASE VERSION : **v1.1.29**

SHA-256 checksum of `index.html` : **3968aacdf1368748c217285a5a3b9f74ea2c871ebfa37f58106c82eff3134090**
SHA-256 checksum of `index.html` : **bb20dc67999768addd0d57cc7d3c3753812c29a7745edb945f2d9b969c93390b**

Find full release code and distribution at : [https://github.com/CTemplar/webclient/releases/latest](https://github.com/CTemplar/webclient/releases/latest)

Expand Down
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ <h1 class="page-title text-secondary">
</div>
</noscript>
<app-root></app-root>
<script type="text/javascript" src="runtime.342720d51562858f718f.js" integrity="sha384-w1QhvFgOowATHniJfQzgZloSFBjJOgwGm71afLp3tipYVSWHgQFmeOTUj42YDbsT" crossorigin="anonymous"></script><script type="text/javascript" src="polyfills.c6cdf1b91f8032c61d53.js" integrity="sha384-8XtHUNH2tfyVAzUAJGrQH+mA64AcRQdcAdn3rJ1SRQ7deHdCYaRDNxouJcZ3EwkE" crossorigin="anonymous"></script><script type="text/javascript" src="scripts.2b355891e0dd05f2cdd5.js" integrity="sha384-mYWPHV3OvTp4Rm5Bb9cerNTGt0LBYdnEEV5CtcuAX5cerXkjPYrVC7KstOfnun6O" crossorigin="anonymous"></script><script type="text/javascript" src="main.05ec734d3a3af2734197.js" integrity="sha384-LVuN237uXnU2mcJrDQhCB04PI+8EiFQ3pdXW2VR8KVK0mlB9TrdAJLTlz/u7bbaj" crossorigin="anonymous"></script></body>
<script type="text/javascript" src="runtime.342720d51562858f718f.js" integrity="sha384-pLJgpXxiGVw1UnZ1/R4B6qT7WwRSAD4qCkQ6ZjXRG4sKVPi3D+GxvPP934V8tY0K" crossorigin="anonymous"></script><script type="text/javascript" src="polyfills.c6cdf1b91f8032c61d53.js" integrity="sha384-8XtHUNH2tfyVAzUAJGrQH+mA64AcRQdcAdn3rJ1SRQ7deHdCYaRDNxouJcZ3EwkE" crossorigin="anonymous"></script><script type="text/javascript" src="scripts.2b355891e0dd05f2cdd5.js" integrity="sha384-mYWPHV3OvTp4Rm5Bb9cerNTGt0LBYdnEEV5CtcuAX5cerXkjPYrVC7KstOfnun6O" crossorigin="anonymous"></script><script type="text/javascript" src="main.bc0ea30afc9ee23447e5.js" integrity="sha384-ojGcjEvHnjr/iLD0UxGDLWpFvUQYnE5yQyeHS7/NQEDI9z7H2U8ObJ/C8HS6NYpw" crossorigin="anonymous"></script></body>

</html>

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/runtime.342720d51562858f718f.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Store } from '@ngrx/store';
import { OnDestroy, TakeUntilDestroy } from 'ngx-take-until-destroy';
import { Observable } from 'rxjs';
import { timer } from 'rxjs/internal/observable/timer';
import { takeUntil } from 'rxjs/operators';
import {
DeleteMail,
Expand Down Expand Up @@ -45,7 +44,6 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {

userState: UserState;

readonly AUTO_REFRESH_DURATION: number = 30000; // duration in milliseconds
readonly destroyed$: Observable<boolean>;

MAX_EMAIL_PAGE_LIMIT: number = 1;
Expand All @@ -54,8 +52,7 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {
PAGE: number = 0;
private searchText: string;
private mailState: MailState;
private isAutoRefreshPaused: boolean;
private isAutoRefreshInitialized: boolean;
private isInitialized: boolean;
private confirmEmptyTrashModalRef: NgbModalRef;

constructor(public store: Store<AppState>,
Expand All @@ -69,6 +66,12 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {
ngOnInit() {
this.store.select(state => state.mail).pipe(takeUntil(this.destroyed$))
.subscribe((mailState: MailState) => {
if (this.mailFolder === MailFolderType.INBOX && mailState.unreadMailsCount && this.mailState &&
this.mailState.unreadMailsCount &&
mailState.unreadMailsCount.inbox > this.mailState.unreadMailsCount.inbox) {
this.mailState = mailState;
this.refresh();
}
this.mailState = mailState;
this.showProgress = !mailState.loaded || mailState.inProgress;
if (this.fetchMails) {
Expand All @@ -81,12 +84,11 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {
.subscribe((user: UserState) => {
this.userState = user;
this.customFolders = user.customFolders;
if (this.fetchMails && this.userState.settings) {
this.LIMIT = user.settings.emails_per_page || 20;
if (this.LIMIT && this.mailFolder !== MailFolderType.SEARCH && !this.isAutoRefreshInitialized) {
this.isAutoRefreshInitialized = true;
if (this.fetchMails && this.userState.settings && user.settings.emails_per_page) {
this.LIMIT = user.settings.emails_per_page;
if (this.LIMIT && this.mailFolder !== MailFolderType.SEARCH && !this.isInitialized) {
this.isInitialized = true;
this.store.dispatch(new GetMails({ limit: user.settings.emails_per_page, offset: this.OFFSET, folder: this.mailFolder }));
this.initializeAutoRefresh();
}
}
});
Expand Down Expand Up @@ -137,20 +139,9 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {
}
}

initializeAutoRefresh() {
if (this.mailFolder === MailFolderType.INBOX) {
timer(this.AUTO_REFRESH_DURATION, this.AUTO_REFRESH_DURATION).pipe(takeUntil(this.destroyed$))
.subscribe(event => {
if (this.mailState && this.mailState.canGetUnreadCount && !this.isAutoRefreshPaused) {
this.refresh();
}
});
}
}

refresh(forceReload: boolean = false, isForcedByUser?: boolean) {
if (!forceReload && this.mailFolder === MailFolderType.INBOX) {
this.store.dispatch(new GetMails({ limit: this.LIMIT, offset: 0, folder: this.mailFolder, read: false, seconds: 30 }));
this.store.dispatch(new GetMails({ limit: this.LIMIT, offset: 0, folder: this.mailFolder, read: false, seconds: 300 }));
} else {
this.store.dispatch(new GetMails({ forceReload, limit: this.LIMIT, offset: this.OFFSET, folder: this.mailFolder }));
if (isForcedByUser) {
Expand Down Expand Up @@ -330,7 +321,6 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {
if (this.PAGE > 0) {
this.PAGE--;
this.OFFSET = this.PAGE * this.LIMIT;
this.pauseAutoRefresh(20);
this.store.dispatch(new GetMails({
inProgress: true,
limit: this.LIMIT,
Expand All @@ -346,7 +336,6 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {
if (((this.PAGE + 1) * this.LIMIT) < this.MAX_EMAIL_PAGE_LIMIT) {
this.OFFSET = (this.PAGE + 1) * this.LIMIT;
this.PAGE++;
this.pauseAutoRefresh(20);
this.store.dispatch(new GetMails({
inProgress: true,
limit: this.LIMIT,
Expand All @@ -358,13 +347,6 @@ export class GenericFolderComponent implements OnInit, OnDestroy, OnChanges {
}
}

pauseAutoRefresh(seconds: number) {
this.isAutoRefreshPaused = true;
setTimeout(() => {
this.isAutoRefreshPaused = false;
}, seconds * 1000);
}


toggleEmailSelection(mail, event) {
mail.marked = event;
Expand Down
6 changes: 3 additions & 3 deletions src/app/mail/mail-sidebar/mail-sidebar.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Inject, OnInit, ViewChild } from '@angular/core';
import { NgbDropdownConfig, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { Component, Inject, OnInit } from '@angular/core';
import { NgbDropdownConfig, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { AppState, MailBoxesState, MailState, UserState } from '../../store/datatypes';
import { Store } from '@ngrx/store';
import { OnDestroy, TakeUntilDestroy } from 'ngx-take-until-destroy';
Expand All @@ -11,7 +11,7 @@ import { DOCUMENT } from '@angular/common';
import { BreakpointsService } from '../../store/services/breakpoint.service';
import { NotificationService } from '../../store/services/notification.service';
import { NavigationEnd, Router } from '@angular/router';
import { DeleteFolder, GetUnreadMailsCount, StopGettingUnreadMailsCount } from '../../store/actions';
import { GetUnreadMailsCount } from '../../store/actions';
import { timer } from 'rxjs/internal/observable/timer';
import { takeUntil } from 'rxjs/operators';

Expand Down
2 changes: 1 addition & 1 deletion src/app/store/effects/mail.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class MailEffects {
getMailsEffect: Observable<any> = this.actions.pipe(
ofType(MailActionTypes.GET_MAILS),
map((action: GetMails) => action.payload),
mergeMap(payload => {
switchMap(payload => {
return this.mailService.getMessages(payload)
.pipe(
map((response) => {
Expand Down
11 changes: 6 additions & 5 deletions src/app/store/reducers/mail.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function reducer(
...state,
loaded: (mails && !action.payload.forceReload) ? true : false,
inProgress: action.payload.inProgress ? true : false,
currentFolder: action.payload.folder as MailFolderType,
mails: mails ? mails : [],
noUnreadCountChange: true,
};
Expand All @@ -36,19 +37,19 @@ export function reducer(
mails = state.mails.filter(item => mailIDs.indexOf(item.id) < 0);
mails = [...mails, ...action.payload.mails];
}
state.folders.set(action.payload.folder, mails);
mails = mails.map((mail: Mail) => {
mail.receiver_list = mail.receiver_display.map((item: EmailDisplay) => item.name).join(', ');
mail.thread_count = mail.children_count + ((action.payload.folder !== MailFolderType.TRASH
|| (action.payload.folder === MailFolderType.TRASH && mail.folder === MailFolderType.TRASH)) ? 1 : 0);
mail.cc = mail.cc ? mail.cc : [];
mail.bcc = mail.bcc ? mail.bcc : [];
mail.receiver = mail.receiver ? mail.receiver : [];
return mail;
});
state.folders.set(action.payload.folder, mails);
if (state.currentFolder !== action.payload.folder) {
mails = state.folders.get(state.currentFolder);
}
return {
...state,
mails,
mails: mails ? mails : [],
loaded: true,
inProgress: false,
noUnreadCountChange: true,
Expand Down

0 comments on commit e6e0541

Please sign in to comment.