forked from cory/tildefriends
		
	ssb: Get saving the about cache off of the main load path.
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| { | ||||
| 	"type": "tildefriends-app", | ||||
| 	"emoji": "🦀", | ||||
| 	"previous": "&PP5y+K7wgLxdkeeb4iqyK1Fb+vwS9LjLJDt2FPrVlpo=.sha256" | ||||
| 	"previous": "&e997wZKsisgdoMKDf52LAk4Vzzdhbp9M25eC68AoReE=.sha256" | ||||
| } | ||||
|   | ||||
| @@ -148,6 +148,7 @@ class TfElement extends LitElement { | ||||
| 	async fetch_about(ids, users) { | ||||
| 		const k_cache_version = 1; | ||||
| 		let cache = await tfrpc.rpc.databaseGet('about'); | ||||
| 		let original_cache = cache; | ||||
| 		cache = cache ? JSON.parse(cache) : {}; | ||||
| 		if (cache.version !== k_cache_version) { | ||||
| 			cache = { | ||||
| @@ -213,7 +214,13 @@ class TfElement extends LitElement { | ||||
| 			} | ||||
| 		} | ||||
| 		cache.last_row_id = max_row_id; | ||||
| 		await tfrpc.rpc.databaseSet('about', JSON.stringify(cache)); | ||||
| 		let new_cache = JSON.stringify(cache); | ||||
| 		if (new_cache !== original_cache) { | ||||
| 			let start_time = new Date(); | ||||
| 			tfrpc.rpc.databaseSet('about', new_cache).then(function() { | ||||
| 				console.log('saving about took', (new Date() - start_time) / 1000); | ||||
| 			}); | ||||
| 		} | ||||
| 		users = users || {}; | ||||
| 		for (let id of Object.keys(cache.about)) { | ||||
| 			users[id] = Object.assign(users[id] || {}, cache.about[id]); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user