0x0ece / yopa-native

0 stars 2 forks source link

Crash when search is enabled and there are less than 2 secrets in default group #77

Closed jacksilv closed 6 years ago

jacksilv commented 6 years ago

If the default group has less than 2 secrets and the total number of secrets > 5, the application crashes at startup

0x0ece commented 6 years ago

Great catch!

FYI (Y = plural), these cases can be easily tested. In App.js, just set:

const EXAMPLE_DATA = true;
const PERSIST_DATA = false;

And then build your own case, e.g. a repro for this one:

    services: [
      new Service({ service: 'medium.com', username: 'mempa', group: 'default' }),
      // new Service({ service: 'github.com', username: 'mempa', group: 'default' }),
      // new Service({ service: 'twitter.com', username: 'mempassword', group: 'default' }),
      new Service({ service: 'google.com', username: 'mempa@example.com', description: 'gmail gplus gdocs', group: 'Important' }),
      new Service({ service: 'google.com', username: 'mempa2@example.com', description: 'gmail gplus gdocs', group: 'Important' }),
      new Service({ service: 'google.com', username: 'mempa3@example.com', description: 'gmail gplus gdocs', group: 'Important' }),
      new Service({ service: 'google.com', username: 'mempa4@example.com', description: 'gmail gplus gdocs', group: 'Important' }),
      new Service({ service: 'facebook.com', username: 'mempa@example.com', group: 'Important' }),
      new Service({ service: 'bankofamerica.com', username: 'mempa@example.com', group: 'Banks' }),
    ],
0x0ece commented 6 years ago

Fixed to avoid the crash, but it's not the desired result.

The issue originated because we need 1+ elements in services if we want to scrollToIndex 1. This means that if we have 5+ services in total, and 0 or 1 visibile in the default group, search was rendered, scrollToIndex set to 1, but there's no such 2nd element to scroll to.

The current fix avoids the crash, but the result is that search is fully visibile.

We should probably replace FlatList with SectionList, and scroll to section 1 when we add search (==section 0). Filed #90.