(id: string)
| 79 | }; |
| 80 | |
| 81 | const loadStoredTab = async (id: string) => { |
| 82 | const stored = getStorage().load<PersistentTab | undefined>( |
| 83 | keyForTab(id), |
| 84 | undefined |
| 85 | ); |
| 86 | if (!stored) { |
| 87 | return undefined; |
| 88 | } |
| 89 | const tab: SQLEditorTab = { |
| 90 | ...defaultSQLEditorTab(), |
| 91 | // Ignore extended fields stored in localStorage since they are migrated |
| 92 | // to extendedTabStore. |
| 93 | ...omit(stored, EXTENDED_TAB_FIELDS), |
| 94 | id, |
| 95 | }; |
| 96 | if (tab.mode !== DEFAULT_SQL_EDITOR_TAB_MODE) { |
| 97 | // Do not enter ADMIN mode initially |
| 98 | tab.mode = DEFAULT_SQL_EDITOR_TAB_MODE; |
| 99 | } |
| 100 | |
| 101 | await fetchExtendedTab(tab, () => { |
| 102 | // When the first time of migration, the extended doc in IndexedDB is not |
| 103 | // found. |
| 104 | // Fallback to the original PersistentTab in LocalStorage if possible. |
| 105 | // This might happen only once to each user, since the second time when a |
| 106 | // tab is saved, extended fields will be migrated, and won't be saved to |
| 107 | // LocalStorage, so the fallback routine won't be hit. |
| 108 | const { statement } = stored as LegacyStoredTab; |
| 109 | if (statement) { |
| 110 | tab.statement = statement; |
| 111 | } |
| 112 | }); |
| 113 | |
| 114 | return tab; |
| 115 | }; |
| 116 | |
| 117 | const entries = [...Object.entries(tabIdListMapByProject)]; |
| 118 | for (const [project, tabIds] of entries) { |
no test coverage detected