Skip to content

Commit

Permalink
more metaSection removal and remove debug output
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <[email protected]>
  • Loading branch information
stevecassidy committed Jul 12, 2024
1 parent 5fc12c3 commit 8a56f39
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 44 deletions.
3 changes: 0 additions & 3 deletions src/gui/components/record/RecordData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ interface RecordDataTypes {
ui_specification: ProjectUIModel;
conflictfields?: string[] | null;
handleChangeTab: Function;
metaSection?: any;
isSyncing?: string;
disabled?: boolean;
isDraftSaving: boolean;
Expand Down Expand Up @@ -137,7 +136,6 @@ export default function RecordData(props: RecordDataTypes) {
revision_id={props.revision_id}
ui_specification={props.ui_specification}
draft_id={props.draft_id}
metaSection={props.metaSection}
handleChangeTab={props.handleChangeTab}
conflictfields={props.conflictfields}
isSyncing={props.isSyncing}
Expand Down Expand Up @@ -201,7 +199,6 @@ export default function RecordData(props: RecordDataTypes) {
revision_id={props.revision_id}
ui_specification={props.ui_specification}
draft_id={props.draft_id}
metaSection={props.metaSection}
disabled={true} // for view of the forms
handleSetIsDraftSaving={props.handleSetIsDraftSaving}
handleSetDraftLastSaved={props.handleSetDraftLastSaved}
Expand Down
1 change: 0 additions & 1 deletion src/gui/components/record/conflict/conflictform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ type ConflictFormProps = {
record_id: RecordID;
view_default?: string;
ui_specification: ProjectUIModel;
metaSection?: any;
revision_id?: null | RevisionID;
type: string;
conflicts: InitialMergeDetails;
Expand Down
12 changes: 1 addition & 11 deletions src/gui/components/record/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type RecordFormProps = {
ui_specification: ProjectUIModel;
conflictfields?: string[] | null;
handleChangeTab?: Function;
metaSection?: any;
isSyncing?: string;
disabled?: boolean;
handleSetIsDraftSaving: Function;
Expand Down Expand Up @@ -702,7 +701,7 @@ class RecordForm extends React.Component<
}

requireDescription(viewName: string) {
if (viewName === null || this.props.metaSection === null) {
if (viewName === null) {
console.warn('The description has not been determined yet');
return '';
}
Expand All @@ -715,15 +714,6 @@ class RecordForm extends React.Component<
return this.props.ui_specification.views[viewName].description;
}

// backwards compatibility - look in the metadata section
if (
viewName !== null &&
this.props.metaSection !== undefined &&
this.props.metaSection[viewName] !== undefined &&
this.props.metaSection[viewName]['sectiondescription' + viewName] !==
undefined
)
return this.props.metaSection[viewName]['sectiondescription' + viewName];
return '';
}

Expand Down
2 changes: 0 additions & 2 deletions src/gui/components/record/read_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ interface RecordReadViewProps {
ui_specification: ProjectUIModel;
conflictfields?: string[] | null;
handleChangeTab?: any;
metaSection?: any;
draft_id?: string;
handleSetIsDraftSaving: Function;
handleSetDraftLastSaved: Function;
Expand Down Expand Up @@ -66,7 +65,6 @@ export default function RecordReadView(props: RecordReadViewProps) {
revision_id={props.revision_id}
ui_specification={props.ui_specification}
draft_id={props.draft_id}
metaSection={props.metaSection}
disabled={true}
handleSetIsDraftSaving={props.handleSetIsDraftSaving}
handleSetDraftLastSaved={props.handleSetDraftLastSaved}
Expand Down
6 changes: 0 additions & 6 deletions src/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ export async function getProjectDB(
if (active_id in metadata_dbs) {
return metadata_dbs[active_id].local;
} else {
console.log(
'%cgetProjectDB',
'background-color: green',
active_id,
metadata_dbs
);
throw `Meta DB of project ${active_id} is not known`;
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/sync/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ const restHandlers = [

const server = setupServer(...restHandlers);

server.events.on('request:start', ({request}) => {
console.log('MSW intercepted:', request.method, request.url);
});
// Start server before all tests
beforeAll(() => server.listen());

Expand Down
5 changes: 2 additions & 3 deletions src/sync/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export const fetchProjectMetadata = async (
// nop
}

console.log('inserting documents');

try {
// insert the two documents
metaDB.put({
Expand All @@ -95,7 +93,8 @@ export const fetchProjectMetadata = async (
_id: 'ui-specification',
});
} catch {
console.log('something went wrong');
// what should we do here?
console.log('something went wrong inserting metadata documents to pouchdb');
}
};

Expand Down
15 changes: 0 additions & 15 deletions src/sync/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,11 @@ export async function getAvailableProjectsFromListing(
const output: ProjectInformation[] = [];
const projects: ProjectObject[] = [];
const listing = getListing(listing_id);
console.log('listing', listing_id, listing);
if (listing) {
const projects_db = listing.projects.local;
const res = await projects_db.allDocs({
include_docs: true,
});
console.log('got project documents', res);
res.rows.forEach(e => {
if (e.doc !== undefined && !e.id.startsWith('_')) {
projects.push(e.doc as ProjectObject);
Expand Down Expand Up @@ -223,7 +221,6 @@ export function delete_project(
active_doc: ExistingActiveDoc,
project_object: ProjectObject
) {
console.log('Deleting project', active_doc, project_object);
// Delete project from memory
const project_id = active_doc.project_id;

Expand Down Expand Up @@ -284,14 +281,6 @@ export async function ensure_project_databases(
true
);

console.log(
'%cmeta database',
'background-color: pink',
meta_did_change,
meta_local,
metadata_dbs
);

const [data_did_change, data_local] = ensure_local_db(
'data',
active_id,
Expand Down Expand Up @@ -329,8 +318,6 @@ export async function ensure_project_databases(
events.emit('data_sync_state', false, active_doc, project_object);
};

console.log('going to get project metadata');

// get project metadata and UiSpec and store them in the db
const listing = getListing(active_doc.listing_id);
await fetchProjectMetadata(listing, active_doc.project_id);
Expand All @@ -356,8 +343,6 @@ export async function ensure_project_databases(
...project_object.data_db,
};

console.log('update_project data connection', data_connection_info);

// set up remote sync for data database
const [, data_remote] = ensure_synced_db(
active_id,
Expand Down

0 comments on commit 8a56f39

Please sign in to comment.