jaros1 / Money-Network

Demo with complementary and alternative money. Implemented in ZeroNet and AngularJS. Focus on privacy, encryption, max data in client and min data on ZeroNet. Work in progress.
GNU General Public License v2.0
4 stars 4 forks source link

JS error. Problem with missing cache_status.timestamps #226

Closed jaros1 closed 7 years ago

jaros1 commented 7 years ago

MoneyNetworkService.get_public_chat dbQuery callback 3: issue #84. cache_status.timestamps is null. res[1] = {"guest":null,"hub":"1PgyTnnACGd1XRdpfiDihgKwYRRnzgz2zh","from_timestamp":1508145257162,"filename":"1508145257162-1508145257162-2-chat.json","to_timestamp":1508145257162,"auth_address":"18DbeZgtVCcLghmtzvg4Uv8uRQAwR8wnDQ","user_seq":2,"pubkey":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0pMuMJyynH1BmhMJ6vvd\nQZplIBgiiOQSqwu2SpYKICm+P1gGNHnICQic/Nuqi9t93rxJLfWCsl0+lCtoJLen\nf78xz4XzEcGPBeBFn2TbQqPO9loylNlaOgiqDG5qcSc9n7yEF0xmpReDGATwzECi\nJrpZBImwhUMO48iS08b4IfQaMsbnUVY8hdUeJiQ831kMkNQLtxWaeRiyn8cTbKQ6\nLXCDG7GDaFN6t+x3cv/xBX06+ykuYQ0gNIBySiIz69RYzhvOkqOQggLWPF+NMW1J\nO6VRqvX7Sybwm51v3kGGKWeX4znvGY+GwVCpwiH+b2hbGZHIqFp9ogimGVE0WPgu\nnwIDAQAB\n-----END PUBLIC KEY-----","size":341,"delete":true}, cache_status = {"is_downloaded":false,"is_pending":false,"size":341,"download_failed_at":[1508151402020]} all.js:15754 Uncaught TypeError: Cannot read property 'length' of undefined at Object. (all.js:15754) at ZeroFrame.onMessage (30-ZeroFrame.js:42) at 30-ZeroFrame.js:7 (anonymous) @ all.js:15754 ZeroFrame.onMessage @ 30-ZeroFrame.js:42 (anonymous) @ 30-ZeroFrame.js:7

                            // any not yet read messages within page context in this file?
                            if (!cache_status.timestamps) {
                                // JS error after public post #84. should not  be a problem any longer ...
                                console.log(pgm + 'issue #84. cache_status.timestamps is null. res[' + i + '] = ' + JSON.stringify(res[i]) +
                                    ', cache_status = ' + JSON.stringify(cache_status));
                            }
                            for (j=0 ; j<cache_status.timestamps.length ; j++) {
                                if (cache_status.timestamps[j] < chat_page_context.last_bottom_timestamp) continue ;
                                get_and_load_chat_file(cache_filename, res[i].size, null, cb2) ;
                                return ;
                            } // for j (timestamps)

127.0.0.1-1508151768995.log

jaros1 commented 7 years ago

The problem is "res[i].auth_address == my_auth_address" in JS code. Dirty test for already "downloadede" optional chat files. Not working when two different users are using same ZeroNet cert. Must use other method to check for already downloaded optional files https://github.com/jaros1/Money-Network/blob/master/js/lib/76-angular-services.js#L5671

jaros1 commented 7 years ago

Simple workaround. cache without timestamps must be failed fileGet:

                            if (cache_status) {
                                if (cache_status.is_pending) {
                                    // ignore and delete - is being process by an other process - and delete res
                                    res[i].delete = true ;
                                    continue ;
                                }
                                if (!cache_status.timestamps) continue ; // must be a failed fileGet. see next steps
                            }