mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Use JMAP rfc8621 section-2 totalEmails, unreadEmails and isSubscribed
This commit is contained in:
parent
c5718057aa
commit
118505f91e
15 changed files with 68 additions and 72 deletions
|
|
@ -229,11 +229,11 @@ export class AppUser extends AbstractApp {
|
|||
|
||||
setFolderHash(result.Folder, result.Hash);
|
||||
|
||||
folderFromCache.messageCountAll(result.MessageCount);
|
||||
folderFromCache.messageCountAll(result.totalEmails);
|
||||
|
||||
let unreadCountChange = (folderFromCache.messageCountUnread() !== result.MessageUnseenCount);
|
||||
let unreadCountChange = (folderFromCache.messageCountUnread() !== result.unreadEmails);
|
||||
|
||||
folderFromCache.messageCountUnread(result.MessageUnseenCount);
|
||||
folderFromCache.messageCountUnread(result.unreadEmails);
|
||||
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folderFromCache.fullName);
|
||||
|
|
|
|||
|
|
@ -148,11 +148,11 @@ folderInformationMultiply = (boot = false) => {
|
|||
|
||||
setFolderHash(item.Folder, item.Hash);
|
||||
|
||||
folder.messageCountAll(item.MessageCount);
|
||||
folder.messageCountAll(item.totalEmails);
|
||||
|
||||
let unreadCountChange = folder.messageCountUnread() !== item.MessageUnseenCount;
|
||||
let unreadCountChange = folder.messageCountUnread() !== item.unreadEmails;
|
||||
|
||||
folder.messageCountUnread(item.MessageUnseenCount);
|
||||
folder.messageCountUnread(item.unreadEmails);
|
||||
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folder.fullName);
|
||||
|
|
|
|||
|
|
@ -158,19 +158,18 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
|| !isArray(expandedFolders)
|
||||
|| !expandedFolders.includes(oCacheFolder.fullName));
|
||||
|
||||
if (oFolder.Extended) {
|
||||
if (oFolder.Extended.Hash) {
|
||||
setFolderHash(oCacheFolder.fullName, oFolder.Extended.Hash);
|
||||
}
|
||||
|
||||
if (null != oFolder.Extended.MessageCount) {
|
||||
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
||||
}
|
||||
|
||||
if (null != oFolder.Extended.MessageUnseenCount) {
|
||||
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
||||
}
|
||||
if (oFolder.Hash) {
|
||||
setFolderHash(oCacheFolder.fullName, oFolder.Hash);
|
||||
}
|
||||
|
||||
if (null != oFolder.totalEmails) {
|
||||
oCacheFolder.messageCountAll(oFolder.totalEmails);
|
||||
}
|
||||
|
||||
if (null != oFolder.unreadEmails) {
|
||||
oCacheFolder.messageCountUnread(oFolder.unreadEmails);
|
||||
}
|
||||
|
||||
return oCacheFolder;
|
||||
});
|
||||
|
||||
|
|
@ -252,7 +251,7 @@ export class FolderModel extends AbstractModel {
|
|||
focused: false,
|
||||
selected: false,
|
||||
edited: false,
|
||||
subscribed: true,
|
||||
isSubscribed: true,
|
||||
checkable: false, // Check for new messages
|
||||
askDelete: false,
|
||||
|
||||
|
|
@ -336,7 +335,7 @@ export class FolderModel extends AbstractModel {
|
|||
|
||||
hasVisibleSubfolders: () => !!folder.subFolders().find(folder => folder.visible()),
|
||||
|
||||
hasSubscriptions: () => folder.subscribed() | !!folder.subFolders().find(
|
||||
hasSubscriptions: () => folder.isSubscribed() | !!folder.subFolders().find(
|
||||
oFolder => {
|
||||
const subscribed = oFolder.hasSubscriptions();
|
||||
return !oFolder.isSystemFolder() && subscribed;
|
||||
|
|
@ -359,13 +358,13 @@ export class FolderModel extends AbstractModel {
|
|||
* - hasVisibleSubfolders()
|
||||
* Or when all below conditions are true:
|
||||
* - selectable()
|
||||
* - subscribed() OR hideUnsubscribed = false
|
||||
* - isSubscribed() OR hideUnsubscribed = false
|
||||
* - FolderType.User
|
||||
* - not kolabType()
|
||||
*/
|
||||
visible: () => {
|
||||
const selectable = folder.canBeSelected(),
|
||||
visible = (folder.subscribed() | !SettingsUserStore.hideUnsubscribed()) && selectable;
|
||||
visible = (folder.isSubscribed() | !SettingsUserStore.hideUnsubscribed()) && selectable;
|
||||
return folder.hasVisibleSubfolders() | visible;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ export class MessageCollectionModel extends AbstractCollectionModel
|
|||
this.Folder
|
||||
this.FolderHash
|
||||
this.Limit
|
||||
this.MessageCount
|
||||
this.MessageUnseenCount
|
||||
this.totalEmails
|
||||
this.unreadEmails
|
||||
this.MessageResultCount
|
||||
this.NewMessages
|
||||
this.Offset
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ {
|
|||
Remote.abort('Folders').post('FolderRename', FolderUserStore.foldersRenaming, {
|
||||
Folder: folder.fullName,
|
||||
NewFolderName: nameToEdit,
|
||||
Subscribe: folder.subscribed() ? 1 : 0
|
||||
Subscribe: folder.isSubscribed() ? 1 : 0
|
||||
})
|
||||
.then(data => {
|
||||
folder.name(nameToEdit/*data.Name*/);
|
||||
|
|
@ -138,7 +138,7 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ {
|
|||
() => {
|
||||
// folderToRemove.flags.push('\\nonexistent');
|
||||
folderToRemove.selectable(false);
|
||||
// folderToRemove.subscribed(false);
|
||||
// folderToRemove.isSubscribed(false);
|
||||
// folderToRemove.checkable(false);
|
||||
if (!folderToRemove.subFolders.length) {
|
||||
removeFolderFromCacheList(folderToRemove.fullName);
|
||||
|
|
@ -170,12 +170,12 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ {
|
|||
}
|
||||
|
||||
toggleFolderSubscription(folder) {
|
||||
let subscribe = !folder.subscribed();
|
||||
let subscribe = !folder.isSubscribed();
|
||||
Remote.request('FolderSubscribe', null, {
|
||||
Folder: folder.fullName,
|
||||
Subscribe: subscribe ? 1 : 0
|
||||
});
|
||||
folder.subscribed(subscribe);
|
||||
folder.isSubscribed(subscribe);
|
||||
}
|
||||
|
||||
toggleFolderCheckable(folder) {
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ export const FolderUserStore = new class {
|
|||
folder.selectable() &&
|
||||
folder.exists &&
|
||||
timeout > folder.expires &&
|
||||
(folder.isSystemFolder() || (folder.subscribed() && (folder.checkable() || !bDisplaySpecSetting)))
|
||||
(folder.isSystemFolder() || (folder.isSubscribed() && (folder.checkable() || !bDisplaySpecSetting)))
|
||||
) {
|
||||
timeouts.push([folder.expires, folder.fullName]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,17 +193,17 @@ MessagelistUserStore.reload = (bDropPagePosition = false, bDropCurrenFolderCache
|
|||
|
||||
setFolderHash(collection.Folder, collection.FolderHash);
|
||||
|
||||
if (null != collection.MessageCount) {
|
||||
folder.messageCountAll(collection.MessageCount);
|
||||
if (null != collection.totalEmails) {
|
||||
folder.messageCountAll(collection.totalEmails);
|
||||
}
|
||||
|
||||
if (null != collection.MessageUnseenCount) {
|
||||
if (pInt(folder.messageCountUnread()) !== pInt(collection.MessageUnseenCount)) {
|
||||
if (null != collection.unreadEmails) {
|
||||
if (pInt(folder.messageCountUnread()) !== pInt(collection.unreadEmails)) {
|
||||
unreadCountChange = true;
|
||||
MessageFlagsCache.clearFolder(folder.fullName);
|
||||
}
|
||||
|
||||
folder.messageCountUnread(collection.MessageUnseenCount);
|
||||
folder.messageCountUnread(collection.unreadEmails);
|
||||
}
|
||||
|
||||
MessagelistUserStore.initUidNextAndNewMessages(folder.fullName, collection.UidNext, collection.NewMessages);
|
||||
|
|
|
|||
|
|
@ -338,14 +338,14 @@ html:not(rl-mobile) {
|
|||
.flagParent {
|
||||
padding: 0 10px 0 5px;
|
||||
}
|
||||
.flagParent::after {
|
||||
content: '☆'; /*⚐*/
|
||||
}
|
||||
&.flag-\\flagged .flagParent::after,
|
||||
&.hasFlaggedSubMessage .flagParent::after {
|
||||
color: orange;
|
||||
content: '★'; /*⚑*/
|
||||
}
|
||||
&:not(.flag-\\flagged):not(.hasFlaggedSubMessage) .flagParent::after {
|
||||
content: '☆'; /*⚐*/
|
||||
}
|
||||
&:not(.flag-\\flagged):not(.hasFlaggedSubMessage) .flagParent:not(:hover) {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,9 +67,8 @@ class FolderInformation implements \JsonSerializable
|
|||
'Flags' => $this->Flags,
|
||||
'PermanentFlags' => $this->PermanentFlags,
|
||||
/*
|
||||
'Messages' => $this->MESSAGES,
|
||||
'Unseen' => $this->UNSEEN,
|
||||
'Recent' => $this->RECENT,
|
||||
'totalEmails' => $this->MESSAGES,
|
||||
'unreadEmails' => $this->UNSEEN,
|
||||
'UidNext' => $this->UIDNEXT,
|
||||
'UidValidity' => $this->UIDVALIDITY,
|
||||
'Highestmodseq' => $this->HIGHESTMODSEQ,
|
||||
|
|
|
|||
|
|
@ -209,8 +209,8 @@ class Folder implements \JsonSerializable
|
|||
$aStatus = $this->oImapFolder->getStatusItems();
|
||||
if ($aStatus && isset($aStatus['MESSAGES'], $aStatus['UNSEEN'], $aStatus['UIDNEXT'])) {
|
||||
$aExtended = array(
|
||||
'MessageCount' => (int) $aStatus['MESSAGES'],
|
||||
'MessageUnseenCount' => (int) $aStatus['UNSEEN'],
|
||||
'totalEmails' => (int) $aStatus['MESSAGES'],
|
||||
'unreadEmails' => (int) $aStatus['UNSEEN'],
|
||||
'UidNext' => (int) $aStatus['UIDNEXT'],
|
||||
// 'Hash' => $this->MailClient()->GenerateFolderHash(
|
||||
// $this->FullName(), $aStatus['MESSAGES'], $aStatus['UIDNEXT'],
|
||||
|
|
@ -223,7 +223,7 @@ class Folder implements \JsonSerializable
|
|||
'Name' => $this->Name(),
|
||||
'FullName' => $this->FullName(),
|
||||
'Delimiter' => (string) $this->Delimiter(),
|
||||
'Subscribed' => $this->bSubscribed,
|
||||
'isSubscribed' => $this->bSubscribed,
|
||||
'Exists' => $this->bExists,
|
||||
'Selectable' => $this->IsSelectable(),
|
||||
'Flags' => $this->FlagsLowerCase(),
|
||||
|
|
|
|||
|
|
@ -546,8 +546,8 @@ class MailClient
|
|||
return array(
|
||||
'Folder' => $sFolderName,
|
||||
'Hash' => $this->GenerateFolderHash($sFolderName, $iCount, $iUidNext, $iHighestModSeq),
|
||||
'MessageCount' => $iCount,
|
||||
'MessageUnseenCount' => $iUnseenCount,
|
||||
'totalEmails' => $iCount,
|
||||
'unreadEmails' => $iUnseenCount,
|
||||
'UidNext' => $iUidNext,
|
||||
'MessagesFlags' => $aFlags,
|
||||
'HighestModSeq' => $iHighestModSeq,
|
||||
|
|
@ -836,8 +836,8 @@ class MailClient
|
|||
$oMessageCollection->Search = $sSearch;
|
||||
$oMessageCollection->ThreadUid = $oParams->iThreadUid;
|
||||
$oMessageCollection->Filtered = '' !== \MailSo\Config::$MessageListPermanentFilter;
|
||||
$oMessageCollection->MessageCount = $iMessageRealCount;
|
||||
$oMessageCollection->MessageUnseenCount = $iMessageUnseenCount;
|
||||
$oMessageCollection->totalEmails = $iMessageRealCount;
|
||||
$oMessageCollection->unreadEmails = $iMessageUnseenCount;
|
||||
|
||||
$aUids = array();
|
||||
$aAllThreads = [];
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ class MessageCollection extends \MailSo\Base\Collection
|
|||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $MessageCount = 0;
|
||||
public $totalEmails = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $MessageUnseenCount = 0;
|
||||
public $unreadEmails = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
|
|
@ -95,8 +95,8 @@ class MessageCollection extends \MailSo\Base\Collection
|
|||
public function jsonSerialize()
|
||||
{
|
||||
return array_merge(parent::jsonSerialize(), array(
|
||||
'MessageCount' => $this->MessageCount,
|
||||
'MessageUnseenCount' => $this->MessageUnseenCount,
|
||||
'totalEmails' => $this->totalEmails,
|
||||
'unreadEmails' => $this->unreadEmails,
|
||||
'MessageResultCount' => $this->MessageResultCount,
|
||||
'Folder' => $this->FolderName,
|
||||
'FolderHash' => $this->FolderHash,
|
||||
|
|
|
|||
|
|
@ -457,8 +457,8 @@ trait Folders
|
|||
$aResult[] = [
|
||||
'Folder' => $aInboxInformation['Folder'],
|
||||
'Hash' => $aInboxInformation['Hash'],
|
||||
'MessageCount' => $aInboxInformation['MessageCount'],
|
||||
'MessageUnseenCount' => $aInboxInformation['MessageUnseenCount'],
|
||||
'totalEmails' => $aInboxInformation['totalEmails'],
|
||||
'unreadEmails' => $aInboxInformation['unreadEmails'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,21 +266,24 @@ trait Response
|
|||
|
||||
if ($mResponse instanceof \MailSo\Mail\Folder)
|
||||
{
|
||||
$aExtended = null;
|
||||
$aResult = $mResponse->jsonSerialize();
|
||||
|
||||
$aStatus = $mResponse->Status();
|
||||
if ($aStatus && isset($aStatus['MESSAGES'], $aStatus['UNSEEN'], $aStatus['UIDNEXT'])) {
|
||||
$aExtended = array(
|
||||
'MessageCount' => (int) $aStatus['MESSAGES'],
|
||||
'MessageUnseenCount' => (int) $aStatus['UNSEEN'],
|
||||
'UidNext' => (int) $aStatus['UIDNEXT'],
|
||||
'Hash' => $this->MailClient()->GenerateFolderHash(
|
||||
$mResponse->FullName(), $aStatus['MESSAGES'], $aStatus['UIDNEXT'],
|
||||
empty($aStatus['HIGHESTMODSEQ']) ? 0 : $aStatus['HIGHESTMODSEQ'])
|
||||
$aResult = \array_merge(
|
||||
$aResult,
|
||||
[
|
||||
'totalEmails' => (int) $aStatus['MESSAGES'],
|
||||
'unreadEmails' => (int) $aStatus['UNSEEN'],
|
||||
'UidNext' => (int) $aStatus['UIDNEXT'],
|
||||
'Hash' => $this->MailClient()->GenerateFolderHash(
|
||||
$mResponse->FullName(), $aStatus['MESSAGES'], $aStatus['UIDNEXT'],
|
||||
empty($aStatus['HIGHESTMODSEQ']) ? 0 : $aStatus['HIGHESTMODSEQ'])
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (null === $this->aCheckableFolder)
|
||||
{
|
||||
if (null === $this->aCheckableFolder) {
|
||||
$aCheckable = \json_decode(
|
||||
$this->SettingsProvider(true)
|
||||
->Load($this->getAccountFromToken())
|
||||
|
|
@ -288,14 +291,9 @@ trait Response
|
|||
);
|
||||
$this->aCheckableFolder = \is_array($aCheckable) ? $aCheckable : array();
|
||||
}
|
||||
$aResult['Checkable'] = \in_array($mResponse->FullName(), $this->aCheckableFolder);
|
||||
|
||||
return \array_merge(
|
||||
$mResponse->jsonSerialize(),
|
||||
array(
|
||||
'Checkable' => \in_array($mResponse->FullName(), $this->aCheckableFolder),
|
||||
'Extended' => $aExtended,
|
||||
)
|
||||
);
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
if ($mResponse instanceof \MailSo\Base\Collection)
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
<span class="e-action fontastic" data-bind="visible: canBeDeleted() && !askDelete(), click: $root.folderForDeletion">🗑</span>
|
||||
</td>
|
||||
<td data-i18n="[title]SETTINGS_FOLDERS/HELP_SHOW_HIDE_FOLDER">
|
||||
<span class="e-action fontastic" data-bind="css: {'unsubscribed-folder':!subscribed()}, visible: canBeSubscribed(), click: $root.toggleFolderSubscription">👁</span>
|
||||
<span class="e-action fontastic" data-bind="css: {'unsubscribed-folder':!isSubscribed()}, visible: canBeSubscribed(), click: $root.toggleFolderSubscription">👁</span>
|
||||
</td>
|
||||
<!-- ko if: $root.displaySpecSetting -->
|
||||
<td data-i18n="[title]SETTINGS_FOLDERS/HELP_CHECK_FOR_NEW_MESSAGES">
|
||||
<span class="e-action" data-bind="css: {'check-folder':checkable(), 'unchecked-folder':!checkable()}, visible: canBeSelected() && subscribed(), click: $root.toggleFolderCheckable">
|
||||
<span class="e-action" data-bind="css: {'check-folder':checkable(), 'unchecked-folder':!checkable()}, visible: canBeSelected() && isSubscribed(), click: $root.toggleFolderCheckable">
|
||||
<i class="icon-check-mark-circle-two"></i>
|
||||
</span>
|
||||
</td>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue