mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #2540 from appwrite/fix-dat-813
This commit is contained in:
@@ -111,7 +111,6 @@ if (!building) {
|
||||
scopedConsoleClient.setProject('console');
|
||||
clientConsole.setEndpoint(endpoint).setProject('console');
|
||||
|
||||
clientRealtime.setEndpoint(endpoint).setProject('console');
|
||||
clientProject.setEndpoint(endpoint).setMode('admin');
|
||||
clientRealtime.setEndpoint(endpoint).setProject('console');
|
||||
}
|
||||
|
||||
+4
-24
@@ -36,6 +36,7 @@
|
||||
expandTabs,
|
||||
databaseRelatedRowSheetOptions,
|
||||
rowPermissionSheet,
|
||||
isWaterfallFromFaker,
|
||||
type Columns
|
||||
} from './store';
|
||||
import { addSubPanel, registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
|
||||
@@ -65,7 +66,6 @@
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
|
||||
import IndexesSuggestions from '../(suggestions)/indexes.svelte';
|
||||
import { showIndexesSuggestions, tableColumnSuggestions } from '../(suggestions)';
|
||||
|
||||
let editRow: EditRow;
|
||||
let editRelatedRow: EditRelatedRow;
|
||||
@@ -76,12 +76,6 @@
|
||||
let selectedOption: Option['name'] = 'String';
|
||||
let createMoreColumns = false;
|
||||
|
||||
/**
|
||||
* adding a lot of fake data will trigger the realtime below
|
||||
* and will keep invalidating the `Dependencies.TABLE` making a lot of API noise!
|
||||
*/
|
||||
let isWaterfallFromFaker = false;
|
||||
|
||||
let columnCreationHandler: ((response: RealtimeResponse) => void) | null = null;
|
||||
|
||||
onMount(() => {
|
||||
@@ -92,21 +86,9 @@
|
||||
response.events.includes('databases.*.tables.*.columns.*') ||
|
||||
response.events.includes('databases.*.tables.*.indexes.*')
|
||||
) {
|
||||
if (isWaterfallFromFaker) {
|
||||
if ($isWaterfallFromFaker) {
|
||||
columnCreationHandler?.(response);
|
||||
}
|
||||
|
||||
// don't invalidate when -
|
||||
// 1. from faker
|
||||
// 2. ai columns creation
|
||||
// 3. ai indexes creation
|
||||
if (
|
||||
!isWaterfallFromFaker &&
|
||||
!$showIndexesSuggestions &&
|
||||
!$tableColumnSuggestions.table
|
||||
) {
|
||||
invalidate(Dependencies.TABLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -308,7 +290,7 @@
|
||||
}
|
||||
|
||||
async function createFakeData() {
|
||||
isWaterfallFromFaker = true;
|
||||
isWaterfallFromFaker.set(true);
|
||||
|
||||
$spreadsheetLoading = true;
|
||||
$randomDataModalState.show = false;
|
||||
@@ -386,10 +368,8 @@
|
||||
$randomDataModalState.value = 25;
|
||||
}
|
||||
|
||||
/* api is too fast! */
|
||||
// await sleep(1250);
|
||||
$spreadsheetLoading = false;
|
||||
isWaterfallFromFaker = false;
|
||||
isWaterfallFromFaker.set(false);
|
||||
|
||||
spreadsheetRenderKey.set(hash(rowIds));
|
||||
}
|
||||
|
||||
+14
@@ -23,6 +23,7 @@
|
||||
type ColumnsWidth,
|
||||
indexes,
|
||||
isCsvImportInProgress,
|
||||
isWaterfallFromFaker,
|
||||
reorderItems,
|
||||
showCreateIndexSheet
|
||||
} from '../store';
|
||||
@@ -55,6 +56,9 @@
|
||||
import { page } from '$app/state';
|
||||
import { debounce } from '$lib/helpers/debounce';
|
||||
import type { PageData } from './$types';
|
||||
import { realtime } from '$lib/stores/sdk';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
|
||||
const {
|
||||
data
|
||||
@@ -140,6 +144,16 @@
|
||||
onMount(() => {
|
||||
columnsOrder = preferences.getColumnOrder(tableId);
|
||||
columnsWidth = preferences.getColumnWidths(tableId + '#columns');
|
||||
|
||||
return realtime.forProject(page.params.region, ['project', 'console'], async (response) => {
|
||||
if (
|
||||
response.events.includes('databases.*.tables.*.columns.*.delete') ||
|
||||
(response.events.includes('databases.*.tables.*.columns.*.update') &&
|
||||
!$isWaterfallFromFaker)
|
||||
) {
|
||||
await invalidate(Dependencies.TABLE);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getColumnStatusBadge(status: string): ComponentProps<Badge>['type'] {
|
||||
|
||||
-3
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { table } from '../store';
|
||||
@@ -9,7 +8,6 @@
|
||||
import { isRelationship } from '../rows/store';
|
||||
import Confirm from '$lib/components/confirm.svelte';
|
||||
import { Layout } from '@appwrite.io/pink-svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
let {
|
||||
@@ -59,7 +57,6 @@
|
||||
: `${selectedColumns.length} columns have been deleted`
|
||||
});
|
||||
|
||||
await invalidate(Dependencies.TABLE);
|
||||
showDelete = false;
|
||||
selectedColumn = Array.isArray(selectedColumn) ? [] : null;
|
||||
} catch (e) {
|
||||
|
||||
+9
@@ -37,6 +37,9 @@
|
||||
import { showCreateColumnSheet } from '../store';
|
||||
import { isSmallViewport } from '$lib/stores/viewport';
|
||||
import { page } from '$app/state';
|
||||
import { realtime } from '$lib/stores/sdk';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
|
||||
let {
|
||||
data
|
||||
@@ -96,6 +99,12 @@
|
||||
|
||||
onMount(() => {
|
||||
columnsWidth = preferences.getColumnWidths(tableId + '#indexes');
|
||||
|
||||
return realtime.forProject(page.params.region, ['project', 'console'], (response) => {
|
||||
if (response.events.includes('databases.*.tables.*.indexes.*')) {
|
||||
invalidate(Dependencies.TABLE);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getColumnStatusBadge(status: string): ComponentProps<Badge>['type'] {
|
||||
|
||||
+1
-1
@@ -475,7 +475,7 @@
|
||||
message: 'Column deleted'
|
||||
});
|
||||
|
||||
invalidate(Dependencies.TABLE);
|
||||
await invalidate(Dependencies.TABLE);
|
||||
|
||||
$databaseColumnSheetOptions.column = null;
|
||||
} catch (error) {
|
||||
|
||||
+6
@@ -28,6 +28,12 @@ export const table = derived(page, ($page) => $page.data.table as Table);
|
||||
export const columns = derived(page, ($page) => $page.data.table.columns as Columns[]);
|
||||
export const indexes = derived(page, ($page) => $page.data.table.indexes as Models.ColumnIndex[]);
|
||||
|
||||
/**
|
||||
* adding a lot of fake data will trigger the realtime below
|
||||
* and will keep invalidating the `Dependencies.TABLE` making a lot of API noise!
|
||||
*/
|
||||
export const isWaterfallFromFaker = writable(false);
|
||||
|
||||
export const tableColumns = writable<Column[]>([]);
|
||||
|
||||
export const isCsvImportInProgress = writable(false);
|
||||
|
||||
Reference in New Issue
Block a user