Skip to content

Commit 6308eeb

Browse files
committed
progress: fixes
1 parent 1e55850 commit 6308eeb

File tree

12 files changed

+36
-18
lines changed

12 files changed

+36
-18
lines changed

backend/src/modules/attachments/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ const attachmentsRouteHandlers = app
4747
// Copy over the relevant query params that the Electric client adds
4848
// so that we return the right part of the Shape log.
4949
originUrl.searchParams.set('live', offlinePrefetch ? 'false' : (live ?? 'false'));
50-
originUrl.searchParams.set('handle', handle);
5150
originUrl.searchParams.set('offset', offset);
51+
if (handle) originUrl.searchParams.set('handle', handle);
5252
if (cursor) originUrl.searchParams.set('cursor', cursor);
5353
if (where) originUrl.searchParams.set('where', where);
5454

backend/src/utils/schema/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const validDomainsSchema = z
163163
export const minimalElectrycSyncQuery = z.object({
164164
table: z.string(),
165165
offset: z.string(),
166-
handle: z.string(),
166+
handle: z.string().optional(),
167167
cursor: z.string().optional(),
168168
live: z.string().optional(),
169169
where: z.string().optional(),

frontend/src/api.gen/sdk.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ export const getPublicCounts = <ThrowOnError extends boolean = true>(options?: O
17211721
* @param {string | string} options.path.orgidorslug - `string | string`
17221722
* @param {string} options.query.table - `string`
17231723
* @param {string} options.query.offset - `string`
1724-
* @param {string} options.query.handle - `string`
1724+
* @param {string=} options.query.handle - `string` (optional)
17251725
* @param {string=} options.query.cursor - `string` (optional)
17261726
* @param {string=} options.query.live - `string` (optional)
17271727
* @param {string=} options.query.where - `string` (optional)

frontend/src/api.gen/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3457,7 +3457,7 @@ export type ShapeProxyData = {
34573457
query: {
34583458
table: string;
34593459
offset: string;
3460-
handle: string;
3460+
handle?: string;
34613461
cursor?: string;
34623462
live?: string;
34633463
where?: string;

frontend/src/api.gen/zod.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ export const zShapeProxyData = z.object({
14581458
query: z.object({
14591459
table: z.string(),
14601460
offset: z.string(),
1461-
handle: z.string(),
1461+
handle: z.optional(z.string()),
14621462
cursor: z.optional(z.string()),
14631463
live: z.optional(z.string()),
14641464
where: z.optional(z.string()),

frontend/src/modules/attachments/delete-attachments.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const DeleteAttachments = ({ entity, attachments, callback, dialog: isDialog }:
2020

2121
const { collection: attachmentCollection } = getAttachmentsCollection(orgIdOrSlug);
2222
const localAttachmentCollection = getLocalAttachmentsCollection(orgIdOrSlug);
23+
localAttachmentCollection.startSyncImmediate();
2324

2425
const onDelete = async () => {
2526
const localDeletionIds: string[] = [];

frontend/src/modules/attachments/helpers/local-file-storage.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ export const LocalFileStorage = {
7373
async changeFile(fileId: string, newData: Partial<CustomUppyFile>): Promise<void> {
7474
try {
7575
const storageKeys = await keys();
76-
if (!storageKeys.length) return undefined;
76+
if (!storageKeys.length) return;
77+
7778
for (const groupKey of storageKeys) {
7879
const group = await get<StoredOfflineData>(groupKey);
79-
if (!group) return undefined;
80+
if (!group || !group.files || !group.files[fileId]) continue;
81+
8082
group.files[fileId] = { ...group.files[fileId], ...newData };
83+
await set(groupKey, group);
8184
}
8285
} catch (error) {
8386
Sentry.captureException(error);

frontend/src/modules/attachments/query.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,19 @@ export const getLocalAttachmentsCollection = (organizationId: string): Collectio
171171

172172
const groupId = files.length > 1 ? nanoid() : null;
173173

174-
return files.map(({ size, preview, id, type, data, meta }) => {
174+
return files.map((file) => {
175+
const name = file.name || file.meta.name;
176+
const filename = `${name}.${file.extension}`;
177+
178+
const size = file.size ? String(file.size) : String(file.data.size);
179+
175180
return {
176-
id,
177-
filename: meta?.name || 'Unnamed file',
178-
name: meta.name,
179-
content_type: type,
180-
size: size ? String(size) : String(data.size),
181-
original_key: preview ?? '',
181+
id: file.id,
182+
filename,
183+
name,
184+
content_type: file.type,
185+
size,
186+
original_key: file.preview ?? '',
182187
thumbnail_key: null,
183188
converted_key: null,
184189
converted_content_type: null,

frontend/src/modules/attachments/table/helpers.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useAttachmentsUploadDialog = () => {
1414
const open = (organizationId: string) => {
1515
const { collection: attachmentCollection } = getAttachmentsCollection(organizationId);
1616
const localAttachmentCollection = getLocalAttachmentsCollection(organizationId);
17+
localAttachmentCollection.startSyncImmediate();
1718

1819
const onComplete = (result: UploadedUppyFile<'attachment'>) => {
1920
const attachments = parseUploadedAttachments(result, organizationId);

frontend/src/modules/attachments/table/table-wrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { useColumns } from '~/modules/attachments/table/columns';
99
import BaseDataTable from '~/modules/attachments/table/table';
1010
import { AttachmentsTableBar } from '~/modules/attachments/table/table-bar';
1111
import type { LiveQueryAttachment } from '~/modules/attachments/types';
12+
import { useLocalSyncAttachments } from '~/modules/attachments/use-local-sync-attachments';
1213
import { AlertWrap } from '~/modules/common/alert-wrap';
1314
import { useSortColumns } from '~/modules/common/data-table/sort-columns';
1415
import type { BaseTableMethods } from '~/modules/common/data-table/types';
1516
import type { EntityPage } from '~/modules/entities/types';
1617
import type { attachmentsSearchSchema } from '~/routes/organizations';
17-
import { useLocalSyncAttachments } from '../use-local-sync-attachments';
1818

1919
const LIMIT = appConfig.requestLimits.attachments;
2020

0 commit comments

Comments
 (0)