Skip to content

Commit

Permalink
[fix] Update remote table sync status in cache after schema update (t…
Browse files Browse the repository at this point in the history
…wentyhq#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
  • Loading branch information
ijreilly committed May 24, 2024
1 parent f9a3d5f commit 4bd0aaf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const useSyncRemoteTableSchemaChanges = () => {
fieldModifiers: {
schemaPendingUpdates: () =>
data.syncRemoteTableSchemaChanges.schemaPendingUpdates || [],
status: () => data.syncRemoteTableSchemaChanges.status,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DistantTableService {
tableName,
);

return distantTables[tableName] || [];
return distantTables[tableName];
}

private async getDistantTablesFromDynamicSchema(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -315,7 +319,7 @@ export class RemoteTableService {
remoteTable.distantTableName,
);

if (isEmpty(distantTableColumns)) {
if (!distantTableColumns) {
await this.unsyncOne(workspaceId, remoteTable, remoteServer);

return {
Expand Down

0 comments on commit 4bd0aaf

Please sign in to comment.