[fix] Update remote table sync status in cache after schema update (#5553)

Upon schema update, sync status can change from synced to non_synced in
case the update regards a table that was deleted. Let's update the sync
status too to avoid displaying the table as still synchronized.


https://github.com/twentyhq/twenty/assets/51697796/7ff2342b-ce9f-4179-9b76-940617cf1292
This commit is contained in:
Marie
2024-05-24 10:20:08 +02:00
committed by GitHub
parent f9a3d5fd15
commit 4bd0aafb8e
3 changed files with 7 additions and 2 deletions

View File

@ -35,6 +35,7 @@ export const useSyncRemoteTableSchemaChanges = () => {
fieldModifiers: {
schemaPendingUpdates: () =>
data.syncRemoteTableSchemaChanges.schemaPendingUpdates || [],
status: () => data.syncRemoteTableSchemaChanges.status,
},
});
}

View File

@ -50,7 +50,7 @@ export class DistantTableService {
tableName,
);
return distantTables[tableName] || [];
return distantTables[tableName];
}
private async getDistantTablesFromDynamicSchema(

View File

@ -194,6 +194,10 @@ export class RemoteTableService {
input.name,
);
if (!distantTableColumns) {
throw new BadRequestException('Table not found');
}
// We only support remote tables with an id column for now.
const distantTableIdColumn = distantTableColumns.find(
(column) => column.columnName === 'id',
@ -315,7 +319,7 @@ export class RemoteTableService {
remoteTable.distantTableName,
);
if (isEmpty(distantTableColumns)) {
if (!distantTableColumns) {
await this.unsyncOne(workspaceId, remoteTable, remoteServer);
return {