mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 13:39:22 +03:00
Activated search subfolders as request by #154
This commit is contained in:
parent
b1038667ee
commit
6c797c34f8
51 changed files with 1024 additions and 874 deletions
|
|
@ -840,7 +840,7 @@ class AppUser extends AbstractApp {
|
|||
if (getFolderInboxName() !== cF) {
|
||||
this.folderInformation(cF);
|
||||
}
|
||||
FolderUserStore.listStatusSupported() || this.folderInformationMultiply(true);
|
||||
FolderUserStore.hasCapability('LIST-STATUS') || this.folderInformationMultiply(true);
|
||||
}, 1000);
|
||||
|
||||
setTimeout(() => Remote.appDelayStart(()=>0), 35000);
|
||||
|
|
|
|||
|
|
@ -37,13 +37,11 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
super();
|
||||
this.CountRec
|
||||
this.FoldersHash
|
||||
this.IsMetadataSupported
|
||||
this.IsThreadsSupported
|
||||
this.IsSortSupported
|
||||
this.IsExtendedSupported
|
||||
this.Namespace;
|
||||
this.Optimized
|
||||
this.SystemFolders
|
||||
this.Capabilities
|
||||
}
|
||||
*/
|
||||
|
||||
|
|
@ -146,11 +144,9 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
AppUserStore.threadsAllowed(!!(Settings.app('useImapThread') && this.IsThreadsSupported));
|
||||
|
||||
FolderUserStore.folderListOptimized(!!this.Optimized);
|
||||
FolderUserStore.sortSupported(!!this.IsSortSupported);
|
||||
FolderUserStore.metadataSupported(!!this.IsMetadataSupported);
|
||||
FolderUserStore.listStatusSupported(!!this.IsListStatusSupported);
|
||||
FolderUserStore.quotaUsage(this.quotaUsage);
|
||||
FolderUserStore.quotaLimit(this.quotaLimit);
|
||||
FolderUserStore.capabilities(this.Capabilities);
|
||||
|
||||
FolderUserStore.sentFolder(normalizeFolder(SettingsGet('SentFolder')));
|
||||
FolderUserStore.draftFolder(normalizeFolder(SettingsGet('DraftFolder')));
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const folderForDeletion = ko.observable(null).deleteAccessHelper();
|
|||
|
||||
export class FoldersUserSettings /*extends AbstractViewSettings*/ {
|
||||
constructor() {
|
||||
this.showKolab = Settings.capa(Capa.Kolab) && FolderUserStore.metadataSupported();
|
||||
this.showKolab = ko.computed(() => FolderUserStore.hasCapability('METADATA') && Settings.capa(Capa.Kolab));
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
this.kolabTypeOptions = ko.observableArray();
|
||||
let i18nFilter = key => i18n('SETTINGS_FOLDERS/TYPE_' + key);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ import { Settings, SettingsGet } from 'Common/Globals';
|
|||
|
||||
export const FolderUserStore = new class {
|
||||
constructor() {
|
||||
addObservablesTo(this, {
|
||||
const self = this;
|
||||
addObservablesTo(self, {
|
||||
/**
|
||||
* To use "checkable" option in /#/settings/folders
|
||||
* When true, getNextFolderNames only lists system and "checkable" folders
|
||||
|
|
@ -19,12 +20,6 @@ export const FolderUserStore = new class {
|
|||
*/
|
||||
displaySpecSetting: false,
|
||||
|
||||
/**
|
||||
* If the IMAP server supports SORT, METADATA
|
||||
*/
|
||||
sortSupported: false,
|
||||
metadataSupported: false,
|
||||
listStatusSupported: false,
|
||||
// sortMode: '',
|
||||
|
||||
quotaLimit: 0,
|
||||
|
|
@ -47,40 +42,42 @@ export const FolderUserStore = new class {
|
|||
foldersInboxUnreadCount: 0
|
||||
});
|
||||
|
||||
this.sortMode = ko.observable('').extend({ limitedList: Object.values(FolderSortMode) });
|
||||
self.sortMode = ko.observable('').extend({ limitedList: Object.values(FolderSortMode) });
|
||||
|
||||
this.namespace = '';
|
||||
self.namespace = '';
|
||||
|
||||
this.folderList = ko.observableArray();
|
||||
self.folderList = ko.observableArray();
|
||||
|
||||
this.currentFolder = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'selected'] });
|
||||
self.capabilities = ko.observableArray();
|
||||
|
||||
this.sieveAllowFileintoInbox = !!SettingsGet('SieveAllowFileintoInbox');
|
||||
self.currentFolder = ko.observable(null).extend({ toggleSubscribeProperty: [self, 'selected'] });
|
||||
|
||||
addComputablesTo(this, {
|
||||
self.sieveAllowFileintoInbox = !!SettingsGet('SieveAllowFileintoInbox');
|
||||
|
||||
draftFolderNotEnabled: () => !this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder(),
|
||||
addComputablesTo(self, {
|
||||
|
||||
currentFolderFullNameRaw: () => (this.currentFolder() ? this.currentFolder().fullNameRaw : ''),
|
||||
draftFolderNotEnabled: () => !self.draftFolder() || UNUSED_OPTION_VALUE === self.draftFolder(),
|
||||
|
||||
currentFolderFullName: () => (this.currentFolder() ? this.currentFolder().fullName : ''),
|
||||
currentFolderFullNameHash: () => (this.currentFolder() ? this.currentFolder().fullNameHash : ''),
|
||||
currentFolderFullNameRaw: () => (self.currentFolder() ? self.currentFolder().fullNameRaw : ''),
|
||||
|
||||
currentFolderFullName: () => (self.currentFolder() ? self.currentFolder().fullName : ''),
|
||||
currentFolderFullNameHash: () => (self.currentFolder() ? self.currentFolder().fullNameHash : ''),
|
||||
|
||||
foldersChanging: () =>
|
||||
this.foldersLoading() | this.foldersCreating() | this.foldersDeleting() | this.foldersRenaming(),
|
||||
self.foldersLoading() | self.foldersCreating() | self.foldersDeleting() | self.foldersRenaming(),
|
||||
|
||||
folderListSystemNames: () => {
|
||||
const list = [getFolderInboxName()],
|
||||
others = [this.sentFolder(), this.draftFolder(), this.spamFolder(), this.trashFolder(), this.archiveFolder()];
|
||||
others = [self.sentFolder(), self.draftFolder(), self.spamFolder(), self.trashFolder(), self.archiveFolder()];
|
||||
|
||||
this.folderList().length &&
|
||||
self.folderList().length &&
|
||||
others.forEach(name => name && UNUSED_OPTION_VALUE !== name && list.push(name));
|
||||
|
||||
return list;
|
||||
},
|
||||
|
||||
folderListSystem: () =>
|
||||
this.folderListSystemNames().map(name => getFolderFromCacheList(name)).filter(v => v)
|
||||
self.folderListSystemNames().map(name => getFolderFromCacheList(name)).filter(v => v)
|
||||
});
|
||||
|
||||
const
|
||||
|
|
@ -93,13 +90,13 @@ export const FolderUserStore = new class {
|
|||
folder && folder.type(type);
|
||||
};
|
||||
|
||||
this.sentFolder.subscribe(fRemoveSystemFolderType(this.sentFolder), this, 'beforeChange');
|
||||
this.draftFolder.subscribe(fRemoveSystemFolderType(this.draftFolder), this, 'beforeChange');
|
||||
this.spamFolder.subscribe(fRemoveSystemFolderType(this.spamFolder), this, 'beforeChange');
|
||||
this.trashFolder.subscribe(fRemoveSystemFolderType(this.trashFolder), this, 'beforeChange');
|
||||
this.archiveFolder.subscribe(fRemoveSystemFolderType(this.archiveFolder), this, 'beforeChange');
|
||||
self.sentFolder.subscribe(fRemoveSystemFolderType(self.sentFolder), self, 'beforeChange');
|
||||
self.draftFolder.subscribe(fRemoveSystemFolderType(self.draftFolder), self, 'beforeChange');
|
||||
self.spamFolder.subscribe(fRemoveSystemFolderType(self.spamFolder), self, 'beforeChange');
|
||||
self.trashFolder.subscribe(fRemoveSystemFolderType(self.trashFolder), self, 'beforeChange');
|
||||
self.archiveFolder.subscribe(fRemoveSystemFolderType(self.archiveFolder), self, 'beforeChange');
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
addSubscribablesTo(self, {
|
||||
sentFolder: fSetSystemFolderType(FolderType.Sent),
|
||||
draftFolder: fSetSystemFolderType(FolderType.Drafts),
|
||||
spamFolder: fSetSystemFolderType(FolderType.Spam),
|
||||
|
|
@ -107,12 +104,19 @@ export const FolderUserStore = new class {
|
|||
archiveFolder: fSetSystemFolderType(FolderType.Archive)
|
||||
});
|
||||
|
||||
this.quotaPercentage = ko.computed(() => {
|
||||
const quota = this.quotaLimit(), usage = this.quotaUsage();
|
||||
self.quotaPercentage = ko.computed(() => {
|
||||
const quota = self.quotaLimit(), usage = self.quotaUsage();
|
||||
return 0 < quota ? Math.ceil((usage / quota) * 100) : 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* If the IMAP server supports SORT, METADATA
|
||||
*/
|
||||
hasCapability(name) {
|
||||
return this.capabilities().includes(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { MessageUserStore } from 'Stores/User/Message';
|
|||
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||
import { FolderUserStore } from 'Stores/User/Folder';
|
||||
|
||||
class AdvancedSearchPopupView extends AbstractViewPopup {
|
||||
constructor() {
|
||||
|
|
@ -17,12 +18,15 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
|
|||
subject: '',
|
||||
text: '',
|
||||
selectedDateValue: -1,
|
||||
selectedTreeValue: '',
|
||||
|
||||
hasAttachment: false,
|
||||
starred: false,
|
||||
unseen: false
|
||||
});
|
||||
|
||||
this.showMultisearch = ko.computed(() => FolderUserStore.hasCapability('MULTISEARCH'));
|
||||
|
||||
let prefix = 'SEARCH/LABEL_ADV_DATE_';
|
||||
this.selectedDates = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
|
|
@ -37,6 +41,16 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
|
|||
];
|
||||
});
|
||||
|
||||
prefix = 'SEARCH/LABEL_ADV_SUBFOLDERS_';
|
||||
this.selectedTree = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
{ id: '', name: i18n(prefix + 'NONE') },
|
||||
{ id: 'subtree-one', name: i18n(prefix + 'SUBTREE_ONE') },
|
||||
{ id: 'subtree', name: i18n(prefix + 'SUBTREE') }
|
||||
];
|
||||
});
|
||||
|
||||
decorateKoCommands(this, {
|
||||
searchCommand: 1
|
||||
});
|
||||
|
|
@ -69,65 +83,54 @@ class AdvancedSearchPopupView extends AbstractViewPopup {
|
|||
});
|
||||
}
|
||||
|
||||
buildSearchStringValue(value) {
|
||||
if (value.includes(' ')) {
|
||||
value = '"' + value + '"';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
buildSearchString() {
|
||||
const result = [],
|
||||
from_ = this.from().trim(),
|
||||
to = this.to().trim(),
|
||||
subject = this.subject().trim(),
|
||||
text = this.text().trim(),
|
||||
isPart = [],
|
||||
hasPart = [];
|
||||
const
|
||||
result = new FormData();
|
||||
|
||||
if (from_) {
|
||||
result.push('from:' + this.buildSearchStringValue(from_));
|
||||
let value = this.from().trim();
|
||||
if (value) {
|
||||
result.set('from', value);
|
||||
}
|
||||
|
||||
if (to) {
|
||||
result.push('to:' + this.buildSearchStringValue(to));
|
||||
value = this.to().trim();
|
||||
if (value) {
|
||||
result.set('to', value);
|
||||
}
|
||||
|
||||
if (subject) {
|
||||
result.push('subject:' + this.buildSearchStringValue(subject));
|
||||
value = this.subject().trim();
|
||||
if (value) {
|
||||
result.set('subject', value);
|
||||
}
|
||||
|
||||
if (this.hasAttachment()) {
|
||||
hasPart.push('attachment');
|
||||
result.set('has', 'attachment');
|
||||
}
|
||||
|
||||
if (this.unseen()) {
|
||||
isPart.push('unseen');
|
||||
result.set('is[]', 'unseen');
|
||||
}
|
||||
|
||||
if (this.starred()) {
|
||||
isPart.push('flagged');
|
||||
}
|
||||
|
||||
if (hasPart.length) {
|
||||
result.push('has:' + hasPart.join(','));
|
||||
}
|
||||
|
||||
if (isPart.length) {
|
||||
result.push('is:' + isPart.join(','));
|
||||
result.set('is[]', 'flagged');
|
||||
}
|
||||
|
||||
if (-1 < this.selectedDateValue()) {
|
||||
let d = new Date();
|
||||
d.setDate(d.getDate() - this.selectedDateValue());
|
||||
result.push('date:' + d.format('Y.m.d') + '/');
|
||||
result.set('date', d.format('Y.m.d') + '/');
|
||||
}
|
||||
|
||||
if (text) {
|
||||
result.push('text:' + this.buildSearchStringValue(text));
|
||||
value = this.selectedTreeValue();
|
||||
if (value) {
|
||||
result.set('in', value);
|
||||
}
|
||||
|
||||
return result.join(' ').trim();
|
||||
value = this.text().trim();
|
||||
if (value) {
|
||||
result.set('text', value);
|
||||
}
|
||||
|
||||
return new URLSearchParams(result).toString();
|
||||
}
|
||||
|
||||
clearPopup() {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ export class MailMessageList extends AbstractViewRight {
|
|||
|
||||
this.messageList = MessageUserStore.list;
|
||||
|
||||
this.sortSupported = FolderUserStore.sortSupported;
|
||||
this.sortSupported = ko.computed(() =>
|
||||
FolderUserStore.hasCapability('SORT') | FolderUserStore.hasCapability('ESORT')
|
||||
);
|
||||
|
||||
this.composeInEdit = AppUserStore.composeInEdit;
|
||||
this.leftPanelDisabled = leftPanelDisabled;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue