mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-30 18:40:08 +00:00 
			
		
		
		
	tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									843e06bebc
								
							
						
					
					
						commit
						c9c50be3cc
					
				
							
								
								
									
										27
									
								
								pwiki2.js
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								pwiki2.js
									
									
									
									
									
								
							| @ -413,13 +413,19 @@ module.store = | |||||||
| // 			- a router?
 | // 			- a router?
 | ||||||
| // 			- substores?
 | // 			- substores?
 | ||||||
| 
 | 
 | ||||||
| // XXX use super...
 | // XXX might be a good idea to normalize args...
 | ||||||
| var metaProxy =  | var metaProxy =  | ||||||
| function(meth){ | function(meth, drop_cache=false, pre){ | ||||||
| 	return function(path, ...args){ | 	return function(path, ...args){ | ||||||
|  | 		if(drop_cache){ | ||||||
|  | 			delete this.__substores } | ||||||
|  | 		if(pre){ | ||||||
|  | 			var res = pre.call(this, path, ...args) | ||||||
|  | 			if(res === false){ | ||||||
|  | 				return }} | ||||||
| 		var store = this.substore(path) | 		var store = this.substore(path) | ||||||
| 		return store != null ? | 		return store == null ? | ||||||
| 			//BaseStore[meth].call(this, path, ...args)
 | 			// XXX this breaks for some reason...
 | ||||||
| 			object.parentCall(MetaStore, meth, this, path, ...args) | 			object.parentCall(MetaStore, meth, this, path, ...args) | ||||||
| 			: this.data[store][meth](path.slice(store.length), ...args) } } | 			: this.data[store][meth](path.slice(store.length), ...args) } } | ||||||
| 
 | 
 | ||||||
| @ -440,7 +446,7 @@ module.MetaStore = { | |||||||
| 		return this.__substores  | 		return this.__substores  | ||||||
| 			?? (this.__substores = Object.entries(this.data) | 			?? (this.__substores = Object.entries(this.data) | ||||||
| 				.filter(function([path, value]){ | 				.filter(function([path, value]){ | ||||||
| 					return object.childOf(value, BaseStore) }) | 					return object.childOf(value, module.BaseStore) }) | ||||||
| 				.map(function([path, _]){ | 				.map(function([path, _]){ | ||||||
| 					return path })) }, | 					return path })) }, | ||||||
| 	substore: function(path){ | 	substore: function(path){ | ||||||
| @ -462,16 +468,19 @@ module.MetaStore = { | |||||||
| 		var data = this.data | 		var data = this.data | ||||||
| 		Object.keys(data) | 		Object.keys(data) | ||||||
| 			.map(function(path){ | 			.map(function(path){ | ||||||
| 				return object.childOf(data[path], BaseStore) ? | 				return object.childOf(data[path], module.BaseStore) ? | ||||||
| 					data[path].paths() | 					data[path].paths() | ||||||
| 					: data[path] }) | 					: data[path] }) | ||||||
| 			.flat() }, | 			.flat() }, | ||||||
| 
 | 
 | ||||||
| 	__exists__: metaProxy('__exists__'), | 	__exists__: metaProxy('__exists__'), | ||||||
| 	__get__: metaProxy('__get__'), | 	__get__: metaProxy('__get__'), | ||||||
| 	__delete__: metaProxy('__delete__'), | 	__delete__: metaProxy('__delete__', true), | ||||||
| 	// XXX need to write a store as-is...
 | 	__update__: metaProxy('__update__', true,  | ||||||
| 	__update__: metaProxy('__update__'), | 		function(path, data, mode){ | ||||||
|  | 			if(object.childOf(data, module.module.BaseStore)){ | ||||||
|  | 				this.data[path] = data | ||||||
|  | 				return false } }), | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user