From ee2369950f604bc5baa6f4bca252d570dd193575 Mon Sep 17 00:00:00 2001 From: Chaiwat Ekkaewnumchai Date: Tue, 12 May 2020 04:53:20 -0700 Subject: [PATCH] Sort Result From ID instead of Using Directly from Result Summary: As mentioned in [the first comment in the Github issue](https://github.com/facebook/flipper/issues/989#issuecomment-616673590), we were mixing database `id` given from client and `index + 1` on server side. After investigating, most are used correctly; it searches `id` from given database `name`. However, there are a few (if not one) that, in my opinion, was used incorrectly. For example, [`tableOption`](https://fburl.com/diffusion/vlo7xbo1) assumed `id - 1` is the index, which is sometime incorrect. This diff sorts the database listed from client by `id` before storing in the state. Changelog: Fixed wrong order assumption on server side Reviewed By: jknoxville Differential Revision: D21496345 fbshipit-source-id: 5e15f776356b0357ac14fbde6c2a11efd76cd1e1 --- desktop/plugins/databases/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/plugins/databases/index.tsx b/desktop/plugins/databases/index.tsx index fe42eb80d..c10862962 100644 --- a/desktop/plugins/databases/index.tsx +++ b/desktop/plugins/databases/index.tsx @@ -445,7 +445,7 @@ export default class DatabasesPlugin extends FlipperPlugin< results: UpdateDatabasesEvent, ): DatabasesPluginState => { const updates = results.databases; - const databases = updates; + const databases = updates.sort((db1, db2) => db1.id - db2.id); const selectedDatabase = state.selectedDatabase || (Object.values(databases)[0]