[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:
@ -35,6 +35,7 @@ export const useSyncRemoteTableSchemaChanges = () => {
|
|||||||
fieldModifiers: {
|
fieldModifiers: {
|
||||||
schemaPendingUpdates: () =>
|
schemaPendingUpdates: () =>
|
||||||
data.syncRemoteTableSchemaChanges.schemaPendingUpdates || [],
|
data.syncRemoteTableSchemaChanges.schemaPendingUpdates || [],
|
||||||
|
status: () => data.syncRemoteTableSchemaChanges.status,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,7 +50,7 @@ export class DistantTableService {
|
|||||||
tableName,
|
tableName,
|
||||||
);
|
);
|
||||||
|
|
||||||
return distantTables[tableName] || [];
|
return distantTables[tableName];
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getDistantTablesFromDynamicSchema(
|
private async getDistantTablesFromDynamicSchema(
|
||||||
|
|||||||
@ -194,6 +194,10 @@ export class RemoteTableService {
|
|||||||
input.name,
|
input.name,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!distantTableColumns) {
|
||||||
|
throw new BadRequestException('Table not found');
|
||||||
|
}
|
||||||
|
|
||||||
// We only support remote tables with an id column for now.
|
// We only support remote tables with an id column for now.
|
||||||
const distantTableIdColumn = distantTableColumns.find(
|
const distantTableIdColumn = distantTableColumns.find(
|
||||||
(column) => column.columnName === 'id',
|
(column) => column.columnName === 'id',
|
||||||
@ -315,7 +319,7 @@ export class RemoteTableService {
|
|||||||
remoteTable.distantTableName,
|
remoteTable.distantTableName,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isEmpty(distantTableColumns)) {
|
if (!distantTableColumns) {
|
||||||
await this.unsyncOne(workspaceId, remoteTable, remoteServer);
|
await this.unsyncOne(workspaceId, remoteTable, remoteServer);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user