Header parser fixes (ISO_2022_JP charset probles) (Closes #355)

+ Small fixes
This commit is contained in:
RainLoop Team 2014-10-18 01:02:19 +04:00
parent 6b0ca800e8
commit 3a9bc849c9
15 changed files with 131 additions and 59 deletions

View file

@ -174,7 +174,7 @@
AppApp.prototype.recacheInboxMessageList = function ()
{
Remote.messageList(Utils.emptyFunction, 'INBOX', 0, Data.messagesPerPage(), '', true);
Remote.messageList(Utils.emptyFunction, Cache.getFolderInboxName(), 0, Data.messagesPerPage(), '', true);
};
AppApp.prototype.reloadMessageListHelper = function (bEmptyList)
@ -220,7 +220,7 @@
var
bSpam = sSpamFolder === oItem['To'],
bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To']
bHam = !bSpam && sSpamFolder === oItem['From'] && Cache.getFolderInboxName() === oItem['To']
;
Remote.messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'],
@ -320,7 +320,7 @@
nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Spam;
break;
case Enums.FolderType.NotSpam:
oMoveFolder = Cache.getFolderFromCacheList('INBOX');
oMoveFolder = Cache.getFolderFromCacheList(Cache.getFolderInboxName());
break;
case Enums.FolderType.Trash:
oMoveFolder = Cache.getFolderFromCacheList(Data.trashFolder());
@ -612,7 +612,7 @@
{
self.reloadMessageList();
}
else if ('INBOX' === oFolder.fullNameRaw)
else if (Cache.getFolderInboxName() === oFolder.fullNameRaw)
{
self.recacheInboxMessageList();
}
@ -1003,7 +1003,7 @@
if (oCacheFolder)
{
Cache.setFolderToCacheList(sFolderFullNameRaw, oCacheFolder);
Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw);
Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw, oCacheFolder);
}
}
@ -1329,12 +1329,12 @@
}
Events.sub('interval.2m', function () {
self.folderInformation('INBOX');
self.folderInformation(Cache.getFolderInboxName());
});
Events.sub('interval.2m', function () {
var sF = Data.currentFolderFullNameRaw();
if ('INBOX' !== sF)
if (Cache.getFolderInboxName() !== sF)
{
self.folderInformation(sF);
}

View file

@ -143,11 +143,13 @@
};
/**
* @param {string} sInboxFolderName = 'INBOX'
* @return {string}
*/
Links.prototype.inbox = function ()
Links.prototype.inbox = function (sInboxFolderName)
{
return this.sBase + 'mailbox/INBOX';
sInboxFolderName = Utils.isUnd(sInboxFolderName) ? 'INBOX' : sInboxFolderName;
return this.sBase + 'mailbox/' + sInboxFolderName;
};
/**

View file

@ -12,6 +12,8 @@
Utils = require('Common/Utils'),
Events = require('Common/Events'),
Cache = require('Storage/App/Cache'),
AbstractModel = require('Knoin/AbstractModel')
;
@ -71,6 +73,8 @@
*/
FolderModel.prototype.initComputed = function ()
{
var sInboxFolderName = Cache.getFolderInboxName();
this.hasSubScribedSubfolders = ko.computed(function () {
return !!_.find(this.subFolders(), function (oFolder) {
return oFolder.subScribed() && !oFolder.isSystemFolder();
@ -165,11 +169,11 @@
var
bSystem = this.isSystemFolder()
;
return !bSystem && 0 === this.subFolders().length && 'INBOX' !== this.fullNameRaw;
return !bSystem && 0 === this.subFolders().length && sInboxFolderName !== this.fullNameRaw;
}, this);
this.canBeSubScribed = ko.computed(function () {
return !this.isSystemFolder() && this.selectable && 'INBOX' !== this.fullNameRaw;
return !this.isSystemFolder() && this.selectable && sInboxFolderName !== this.fullNameRaw;
}, this);
// this.visible.subscribe(function () {
@ -325,7 +329,11 @@
*/
FolderModel.prototype.initByJson = function (oJsonFolder)
{
var bResult = false;
var
bResult = false,
sInboxFolderName = Cache.getFolderInboxName()
;
if (oJsonFolder && 'Object/Folder' === oJsonFolder['@Object'])
{
this.name(oJsonFolder.Name);
@ -338,7 +346,7 @@
this.existen = !!oJsonFolder.IsExists;
this.subScribed(!!oJsonFolder.IsSubscribed);
this.type('INBOX' === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User);
this.type(sInboxFolderName === this.fullNameRaw ? Enums.FolderType.Inbox : Enums.FolderType.User);
bResult = true;
}

View file

@ -102,6 +102,7 @@
MailBoxAppScreen.prototype.onStart = function ()
{
var
sInboxFolderName = Cache.getFolderInboxName(),
fResizeFunction = function () {
Utils.windowResize();
}
@ -113,9 +114,9 @@
}
_.delay(function () {
if ('INBOX' !== Data.currentFolderFullNameRaw())
if (sInboxFolderName !== Data.currentFolderFullNameRaw())
{
require('App/App').folderInformation('INBOX');
require('App/App').folderInformation(sInboxFolderName);
}
}, 1000);
@ -152,8 +153,9 @@
MailBoxAppScreen.prototype.routes = function ()
{
var
sInboxFolderName = Cache.getFolderInboxName(),
fNormP = function () {
return ['INBOX', 1, '', true];
return [sInboxFolderName, 1, '', true];
},
fNormS = function (oRequest, oVals) {
oVals[0] = Utils.pString(oVals[0]);
@ -163,7 +165,7 @@
if ('' === oRequest)
{
oVals[0] = 'INBOX';
oVals[0] = sInboxFolderName;
oVals[1] = 1;
}
@ -175,7 +177,7 @@
if ('' === oRequest)
{
oVals[0] = 'INBOX';
oVals[0] = sInboxFolderName;
}
return [decodeURI(oVals[0]), 1, decodeURI(oVals[1]), false];

View file

@ -162,6 +162,19 @@
this.oNewMessage = {};
};
/**
* @type {string}
*/
CacheAppStorage.prototype.sInboxFolderName = '';
/**
* @return {string}
*/
CacheAppStorage.prototype.getFolderInboxName = function ()
{
return '' === this.sInboxFolderName ? 'INBOX' : this.sInboxFolderName;
};
/**
* @param {string} sFolderHash
* @return {string}
@ -178,6 +191,10 @@
CacheAppStorage.prototype.setFolderFullNameRaw = function (sFolderHash, sFolderFullNameRaw)
{
this.oFoldersNamesCache[sFolderHash] = sFolderFullNameRaw;
if ('INBOX' === sFolderFullNameRaw || '' === this.sInboxFolderName)
{
this.sInboxFolderName = sFolderFullNameRaw;
}
};
/**

View file

@ -187,7 +187,7 @@
this.folderListSystemNames = ko.computed(function () {
var
aList = ['INBOX'],
aList = [Cache.getFolderInboxName()],
aFolders = this.folderList(),
sSentFolder = this.sentFolder(),
sDraftFolder = this.draftFolder(),
@ -531,7 +531,7 @@
DataAppStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUidNext, aNewMessages)
{
if ('INBOX' === sFolder && Utils.isNormal(sUidNext) && sUidNext !== '')
if (Cache.getFolderInboxName() === sFolder && Utils.isNormal(sUidNext) && sUidNext !== '')
{
if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length)
{
@ -632,8 +632,9 @@
iTimeout = iUtc - 60 * 5,
aTimeouts = [],
fSearchFunction = function (aList) {
var sInboxFolderName = Cache.getFolderInboxName();
_.each(aList, function (oFolder) {
if (oFolder && 'INBOX' !== oFolder.fullNameRaw &&
if (oFolder && sInboxFolderName !== oFolder.fullNameRaw &&
oFolder.selectable && oFolder.existen &&
iTimeout > oFolder.interval &&
(!bBoot || oFolder.subScribed()))

View file

@ -251,7 +251,7 @@
sSearch,
Data.projectHash(),
sFolderHash,
'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
Cache.getFolderInboxName() === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
Data.threading() && Data.useThreads() ? '1' : '0',
Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']);
@ -263,7 +263,7 @@
'Offset': iOffset,
'Limit': iLimit,
'Search': sSearch,
'UidNext': 'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
'UidNext': Cache.getFolderInboxName() === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
'UseThreads': Data.threading() && Data.useThreads() ? '1' : '0',
'ExpandedThreadUid': Data.threading() && sFolderFullNameRaw === Data.messageListThreadFolder() ? Data.messageListThreadUids().join(',') : ''
}, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, '', bSilent ? [] : ['MessageList']);
@ -375,7 +375,7 @@
this.defaultRequest(fCallback, 'FolderInformation', {
'Folder': sFolder,
'FlagsUids': Utils.isArray(aUids) ? aUids.join(',') : '',
'UidNext': 'INBOX' === sFolder ? Cache.getFolderUidNext(sFolder) : ''
'UidNext': Cache.getFolderInboxName() === sFolder ? Cache.getFolderUidNext(sFolder) : ''
});
}
else if (Data.useThreads())

View file

@ -9,6 +9,8 @@
Globals = require('Common/Globals'),
Links = require('Common/Links'),
Cache = require('Storage/App/Cache'),
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView')
;
@ -40,7 +42,7 @@
MenuSettingsAppView.prototype.backToMailBoxClick = function ()
{
kn.setHash(Links.inbox());
kn.setHash(Links.inbox(Cache.getFolderInboxName()));
};
module.exports = MenuSettingsAppView;

View file

@ -11,6 +11,7 @@
Links = require('Common/Links'),
Data = require('Storage/App/Data'),
Cache = require('Storage/App/Cache'),
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView')
@ -45,7 +46,7 @@
PaneSettingsAppView.prototype.backToMailBoxClick = function ()
{
kn.setHash(Links.inbox());
kn.setHash(Links.inbox(Cache.getFolderInboxName()));
};
module.exports = PaneSettingsAppView;