Clean up
This commit is contained in:
+5
-11
@@ -10,8 +10,6 @@ const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataPr
|
||||
// In the future, it may use offset-based or cursor-based pagination, which would work with this stateless data provider.
|
||||
// Fortunately, Refine handle pagination automatically if the total number of objects is larger than the page size.
|
||||
getList: async ({ resource, pagination, sorters, filters, meta }) => {
|
||||
console.log('list', resource, pagination, sorters, filters, meta);
|
||||
|
||||
const objects = await getObjects(shapeTypes[resource], {
|
||||
graphs: [""],
|
||||
orderBy: sorters && sorters.length > 0
|
||||
@@ -19,8 +17,12 @@ const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataPr
|
||||
: undefined,
|
||||
where: filters && filters.length > 0
|
||||
? filters.reduce((acc, filter) => {
|
||||
if ("field" in filter && filter.operator === "eq") {
|
||||
if ("field" in filter) {
|
||||
if (filter.operator === "eq") {
|
||||
acc[filter.field] = filter.value;
|
||||
} else {
|
||||
console.warn(`Unsupported filter operator: ${filter.operator}. Only "eq" is supported.`);
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}, {} as any)
|
||||
@@ -33,8 +35,6 @@ const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataPr
|
||||
};
|
||||
},
|
||||
create: async ({ resource, variables, meta }) => {
|
||||
console.log("create", resource, variables, meta);
|
||||
|
||||
const session = authProvider.getSession();
|
||||
|
||||
const docNuri = await ng.doc_create(
|
||||
@@ -61,8 +61,6 @@ const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataPr
|
||||
};
|
||||
},
|
||||
update: async ({ resource, id, variables, meta }) => {
|
||||
console.log('update', resource, id, variables, meta);
|
||||
|
||||
const set = await getSignalObject(shapeTypes[resource], [`${id}`]);
|
||||
|
||||
const oldData = set.first()!;
|
||||
@@ -86,8 +84,6 @@ const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataPr
|
||||
};
|
||||
},
|
||||
deleteOne: async ({ resource, id, variables, meta }) => {
|
||||
console.log('deleteOne', resource, id, variables, meta);
|
||||
|
||||
const set = await getSignalObject(shapeTypes[resource], [`${id}`]);
|
||||
|
||||
const oldData = set.first()!;
|
||||
@@ -99,8 +95,6 @@ const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataPr
|
||||
};
|
||||
},
|
||||
getOne: async ({ resource, id, meta }) => {
|
||||
console.log('getOne', resource, id, meta);
|
||||
|
||||
// The ID should be a graph URI, but if it's an object key, we can use the subjects filter to the the object
|
||||
const objects = await getObjects(shapeTypes[resource], isGraphKey(id) ? { graphs: [`${id}`] } : { graphs: [""], subjects: [`${id}`] });
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ import { LiveProviderConfig, UnwatchFn } from "./types";
|
||||
|
||||
const liveProvider = ({ shapeTypes }: LiveProviderConfig) : LiveProvider => ({
|
||||
subscribe: async ({ channel, params, types, callback, meta }) : Promise<UnwatchFn> => {
|
||||
console.log('subscribe', channel, params?.subscriptionType, params, types, meta);
|
||||
|
||||
const ids = params?.ids as string[];
|
||||
|
||||
if (channel.startsWith("resources/")) {
|
||||
@@ -18,9 +16,7 @@ const liveProvider = ({ shapeTypes }: LiveProviderConfig) : LiveProvider => ({
|
||||
// We don't close the subscription because we want to keep listening for changes
|
||||
const set = await getSignalObject(shapeTypes[resource], ids, false);
|
||||
|
||||
const { stopListening } = watch(set, ({ newValue, patches }) => {
|
||||
console.log('object modified', newValue, patches);
|
||||
|
||||
const { stopListening } = watch(set, ({ patches }) => {
|
||||
const modifiedIds = parsePatches(patches);
|
||||
|
||||
for( const [graphId, eventType] of Object.entries(modifiedIds)) {
|
||||
@@ -39,8 +35,7 @@ const liveProvider = ({ shapeTypes }: LiveProviderConfig) : LiveProvider => ({
|
||||
// We don't close the subscription because we want to keep listening for changes
|
||||
const set = await getSignalObject(shapeTypes[resource], undefined, false);
|
||||
|
||||
const { stopListening } = watch(set, ({ newValue, patches }) => {
|
||||
console.log('objects list modified', newValue, patches);
|
||||
const { stopListening } = watch(set, ({ patches }) => {
|
||||
|
||||
const modifiedIds = parsePatches(patches);
|
||||
|
||||
@@ -62,7 +57,6 @@ const liveProvider = ({ shapeTypes }: LiveProviderConfig) : LiveProvider => ({
|
||||
return () => undefined;
|
||||
},
|
||||
unsubscribe: async (unwatchFn: UnwatchFn | Promise<UnwatchFn>) => {
|
||||
console.log('unsubscribe', unwatchFn);
|
||||
const fn = await Promise.resolve(unwatchFn);
|
||||
if (typeof fn === "function") {
|
||||
fn();
|
||||
|
||||
Reference in New Issue
Block a user