mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: restore post-create table ai suggestions
This commit is contained in:
+19
@@ -11,6 +11,7 @@
|
||||
import { tablesSearcher } from '$lib/commandCenter/searchers';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { showCreateEntity, randomDataModalState, resetSampleFieldsConfig } from './store';
|
||||
import { entityColumnSuggestions } from './(suggestions)/store';
|
||||
import { TablesPanel } from '$lib/commandCenter/panels';
|
||||
import { canWriteTables, canWriteDatabases } from '$lib/stores/roles';
|
||||
import { showCreateBackup, showCreatePolicy } from './backups/store';
|
||||
@@ -25,6 +26,7 @@
|
||||
import type { Snippet } from 'svelte';
|
||||
import { Input as SuggestionsInput } from '$database/(suggestions)/index';
|
||||
import { Modal } from '$lib/components';
|
||||
import { subNavigation } from '$lib/stores/database';
|
||||
|
||||
let {
|
||||
children
|
||||
@@ -42,6 +44,7 @@
|
||||
$registerSearchers(tablesSearcher);
|
||||
|
||||
async function createEntity(entityId: string, name: string, dimension?: number) {
|
||||
const shouldSuggestColumns = $entityColumnSuggestions.enabled;
|
||||
const entity = await databaseSdk.createEntity({
|
||||
databaseId,
|
||||
entityId,
|
||||
@@ -50,6 +53,7 @@
|
||||
});
|
||||
|
||||
await invalidate(Dependencies.DATABASE);
|
||||
await invalidate(Dependencies.TABLES);
|
||||
await goto(
|
||||
withPath(
|
||||
resolveRoute(
|
||||
@@ -60,6 +64,21 @@
|
||||
)
|
||||
);
|
||||
|
||||
subNavigation.update();
|
||||
|
||||
if (shouldSuggestColumns) {
|
||||
entityColumnSuggestions.update((store) => ({
|
||||
...store,
|
||||
enabled: true,
|
||||
thinking: true,
|
||||
force: true,
|
||||
entity: {
|
||||
id: entity.$id,
|
||||
name: entity.name
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
|
||||
+21
@@ -27,6 +27,7 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import { subNavigation } from '$lib/stores/database';
|
||||
import { sleep } from '$lib/helpers/promises';
|
||||
import {
|
||||
type Entity,
|
||||
type EntityList,
|
||||
@@ -83,6 +84,26 @@
|
||||
databaseId: page.params.database,
|
||||
queries: [Query.orderDesc(''), Query.limit(100)]
|
||||
});
|
||||
|
||||
const currentEntityId = page.params[entityTypeSingular];
|
||||
|
||||
if (
|
||||
currentEntityId &&
|
||||
!entities.entities.some((entity: Entity) => entity.$id === currentEntityId)
|
||||
) {
|
||||
for (let attempt = 0; attempt < 3; attempt++) {
|
||||
await sleep(250);
|
||||
|
||||
entities = await databaseSdk.listEntities({
|
||||
databaseId: page.params.database,
|
||||
queries: [Query.orderDesc(''), Query.limit(100)]
|
||||
});
|
||||
|
||||
if (entities.entities.some((entity: Entity) => entity.$id === currentEntityId)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user