RayKaZe / CATS

2 stars 0 forks source link

Fix for race condition between syncing cards and displaying config page #33

Closed LiyouZhou closed 8 years ago

LiyouZhou commented 8 years ago

Now config page is launched only at end of sync_database() procedure

@jgillard Prototyped a fix. Seem to work in paramilitary testing. Please verify if you have time.

This problem can be better solved when we have localstorage implemented.

jgillard commented 8 years ago

The settings page isn't loading for me. Did you see this?

LiyouZhou commented 8 years ago

@jgillard Just tried this on both emulator and phone, works for me. The page takes some time to load because it needs to wait for the sync to finish. But it loads eventually. Can you give more debug information here?

jgillard commented 8 years ago

This is what I'm seeing when I open the settings in the phone app.

[20:32:18] javascript> JS: Card And Ticket Storage: Sync Database
[20:32:18] javascript> JS: Card And Ticket Storage: AppMessage Payload: {"NUM_ENTRIES":1}
[20:32:18] javascript> JS: Card And Ticket Storage: Getting entry 1
[20:32:19] javascript> JS: Card And Ticket Storage: Sending settings data...
[20:32:19] database.c:41> get 1th entry
[20:32:19] database.c:96> get entry: key 0
[20:32:19] database.c:120> Entry 0: Title: Bdjfb do, Data: 5288373782
[20:32:19] javascript> JS: Card And Ticket Storage: Got entry 1
[20:32:19] app_comms.c:107> App Message Outbox Sent.
jgillard commented 8 years ago

Get the right behaviour through the emulator so that's enough to approve this PR.

[20:36:28] javascript> Sync Database
[20:36:28] javascript> AppMessage Payload: {"2":1,"NUM_ENTRIES":1}
[20:36:28] javascript> Getting entry 1
[20:36:28] javascript> Sending settings data...
[20:36:28] app_comms.c:107> App Message Outbox Sent.
[20:36:28] database.c:41> get 1th entry
[20:36:28] database.c:96> get entry: key 0
[20:36:28] database.c:120> Entry 0: Title: 12356754, Data: tesco
[20:36:28] javascript> AppMessage Payload: {"0":"12356754","1":"tesco","3":1,"KEY_CARDNAME":"12356754","KEY_CARDNUMBER":"tesco","GET_NTH_ENTRY":1}
[20:36:28] javascript> Entry 1 contains [object Object]
[20:36:28] javascript> In cards array when settings opened:
[20:36:28] javascript> [{"0":"12356754","1":"tesco","3":1,"KEY_CARDNAME":"12356754","KEY_CARDNUMBER":"tesco","GET_NTH_ENTRY":1}]
[20:36:28] javascript> change something on the html
[20:36:28] javascript> Got entry 1
[20:36:28] app_comms.c:107> App Message Outbox Sent.