@ -200,6 +200,8 @@ function saveDMsToStorage() {
@@ -200,6 +200,8 @@ function saveDMsToStorage() {
} ;
}
pool = twister . var . key . pub . encrypt ( JSON . stringify ( pool ) ) ;
delete pool . orig ; // WORKAROUND the decrypt function does .slice(0, orig) but something goes wrong in process of buffer decoding (if original string contains non-ASCII characters) and orig may be smaller than the actual size, if it is undefined .slice gets it whole
$ . initNamespaceStorage ( defaultScreenName ) . localStorage . set ( 'DMs' , pool ) ;
}
@ -208,6 +210,12 @@ function loadDMsFromStorage() {
@@ -208,6 +210,12 @@ function loadDMsFromStorage() {
if ( storage . isSet ( 'DMs' ) ) {
var pool = storage . get ( 'DMs' ) ;
if ( pool . key && pool . body && pool . mac ) {
if ( pool = twister . var . key . decrypt ( pool ) )
pool = JSON . parse ( pool . toString ( ) ) ;
else
console . warn ( 'can\'t decrypt DMs\' data cache' ) ;
}
if ( typeof pool === 'object' ) {
for ( var peerAlias in pool ) {
if ( ! twister . DMs [ peerAlias ] )
@ -454,6 +462,9 @@ function updateGroupList() {
@@ -454,6 +462,9 @@ function updateGroupList() {
function initDMsCount ( ) {
twister . DMs = { } ;
dumpPrivkey ( defaultScreenName , function ( req , res ) {
twister . var . key = TwisterCrypto . PrivKey . fromWIF ( res ) ;
loadDMsFromStorage ( ) ;
$ . MAL . updateNewDMsUI ( getNewDMsCount ( ) ) ;
$ . MAL . updateNewGroupDMsUI ( getNewGroupDMsCount ( ) ) ;
@ -464,6 +475,7 @@ function initDMsCount() {
@@ -464,6 +475,7 @@ function initDMsCount() {
setTimeout ( requestDMsCount , 200 ) ;
//polling not needed: processNewPostsConfirmation will call requestDMsCount.
//setInterval('requestDMsCount()', 5000);
} ) ;
}
function newmsgsChangedUser ( ) {