members icon in thread list
							parent
							
								
									779aaece08
								
							
						
					
					
						commit
						8f51958dca
					
				|  | @ -243,6 +243,13 @@ | ||||||
| 				padding: 2px 3px; | 				padding: 2px 3px; | ||||||
| 				white-space: pre; | 				white-space: pre; | ||||||
| 				cursor: default; | 				cursor: default; | ||||||
|  | 				display: flex; | ||||||
|  | 				justify-content: space-between; | ||||||
|  | 				align-items: center; | ||||||
|  | 			} | ||||||
|  | 			#membericon { | ||||||
|  | 				height: 18px; | ||||||
|  | 				filter: brightness(.75); | ||||||
| 			} | 			} | ||||||
| 			#createthread { | 			#createthread { | ||||||
| 				max-width: fit-content; | 				max-width: fit-content; | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 7.0 KiB | 
|  | @ -391,9 +391,11 @@ async function loadThreads(instancediv, select) { | ||||||
| 				else | 				else | ||||||
| 					document.getElementById('thread').classList.remove('hidden'); | 					document.getElementById('thread').classList.remove('hidden'); | ||||||
| 				openThread(this, true); | 				openThread(this, true); | ||||||
| 			}}>${ | 			}}><span id='name'>${ | ||||||
| 				thread.name | 				thread.name | ||||||
| 			}</div>`; | 			}</span></div>`; | ||||||
|  | 		if (!thread.permissions.public) | ||||||
|  | 			node.insertAdjacentHTML('beforeend', `<img id='membericon' src='/members.png'>`); | ||||||
| 		node.id = 'thread' + thread.id; | 		node.id = 'thread' + thread.id; | ||||||
| 		node.thread = thread; | 		node.thread = thread; | ||||||
| 		thread.div = node; | 		thread.div = node; | ||||||
|  | @ -480,7 +482,11 @@ async function loadThreads(instancediv, select) { | ||||||
| 			let el = threadlist.children['thread' + thread.id]; | 			let el = threadlist.children['thread' + thread.id]; | ||||||
| 			if (el) { | 			if (el) { | ||||||
| 				Object.assign(el.thread, thread); | 				Object.assign(el.thread, thread); | ||||||
| 				el.textContent = thread.name; | 				el.children['name'].textContent = thread.name; | ||||||
|  | 				if (!thread.permissions.everyone.view.value && !el.children['membericon']) | ||||||
|  | 					el.insertAdjacentHTML('beforeend', `<img id='membericon' src='/members.png'>`); | ||||||
|  | 				else if (el.children['membericon'] && thread.permissions.everyone.value) | ||||||
|  | 					el.children['membericon'].remove(); | ||||||
| 				if (window.currentThread?.id === thread.id) { | 				if (window.currentThread?.id === thread.id) { | ||||||
| 					Object.assign(window.currentThread, thread); | 					Object.assign(window.currentThread, thread); | ||||||
| 					document.getElementById('threadname').textContent = thread.name; | 					document.getElementById('threadname').textContent = thread.name; | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 13 KiB | 
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 24 KiB | 
|  | @ -0,0 +1 @@ | ||||||
|  | <svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m4.50210155 9.3741201c-.90792683-.63231469-1.50210155-1.68382892-1.50210155-2.8741201 0-1.93299662 1.56700338-3.5 3.5-3.5s3.5 1.56700338 3.5 3.5c0 1.19029118-.59417472 2.24180541-1.50210155 2.8741201 2.04978735.7995265 3.50210155 2.7931001 3.50210155 5.1258799 0 .1685448-.0075813.335319-.0224215.5h-1.0050429c.0181477-.1641669.0274644-.3309955.0274644-.5 0-2.4852814-2.01471863-4.5-4.5-4.5s-4.5 2.0147186-4.5 4.5c0 .1690045.00931666.3358331.02746439.5h-1.00504288c-.0148402-.164681-.02242151-.3314552-.02242151-.5 0-2.3327798 1.45231416-4.3263534 3.50210155-5.1258799zm1.99789845-.3741201c1.38071187 0 2.5-1.11928813 2.5-2.5s-1.11928813-2.5-2.5-2.5-2.5 1.11928813-2.5 2.5 1.11928813 2.5 2.5 2.5zm4.1848662-.84237851c.2033423-.51293024.3151105-1.07213331.3151338-1.65743839.6072233-.45610317 1-1.18227418 1-2.0001831 0-1.38071187-1.1192881-2.5-2.5-2.5-.46298477 0-.89657462.12585463-1.26842436.3452187-.38009908-.15859607-.78660552-.26655309-1.21109072-.31544242.63373868-.63610749 1.51065375-1.02977628 2.47951508-1.02977628 1.9329966 0 3.5 1.56700338 3.5 3.5 0 1.19029118-.5941747 2.24180541-1.5021015 2.8741201 2.0497873.79952654 3.5021015 2.7931001 3.5021015 5.1258799 0 .1685448-.0075813.335319-.0224215.5h-1.0050429c.0181477-.1641669.0274644-.3309955.0274644-.5 0-2.0752021-1.4047016-3.8223186-3.3151338-4.34237851z" fill="#293040"/></svg> | ||||||
| After Width: | Height: | Size: 1.4 KiB | 
|  | @ -154,7 +154,6 @@ async function create_thread(msg, respond) { | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	// respond
 |  | ||||||
| 	return respond({ | 	return respond({ | ||||||
| 		success: true, | 		success: true, | ||||||
| 		id: thread_id | 		id: thread_id | ||||||
|  | @ -164,24 +163,27 @@ async function create_thread(msg, respond) { | ||||||
| async function list_threads(msg, respond) { | async function list_threads(msg, respond) { | ||||||
| 	// this can be optimized by merging the permission check into here
 | 	// this can be optimized by merging the permission check into here
 | ||||||
| 	let threads = await db.query( | 	let threads = await db.query( | ||||||
| 		`select name, id from thread
 | 		`select name, id, eperm.value from thread
 | ||||||
|  | 		left join permission as eperm on thread.id = eperm.thread | ||||||
|  | 			and eperm.type = 'everyone' and eperm.permission = 'view' | ||||||
| 		join permission on thread.id = permission.thread | 		join permission on thread.id = permission.thread | ||||||
| 		left join member on thread.id = member.thread | 		left join member on thread.id = member.thread | ||||||
| 		where permission.permission = 'view' and permission.value = 'true' | 		where permission.permission = 'view' and permission.value = 'true' | ||||||
| 		and ((permission.type = 'everyone') or | 		and (permission.type = 'everyone' or | ||||||
| 			permission.type = 'members' and member.user = ?) | 			permission.type = 'members' and member.user = ?) | ||||||
| 		group by thread.id | 		group by thread.id | ||||||
| 		order by thread.created desc`,
 | 		order by thread.created desc`,
 | ||||||
| 		msg.auth_user.id | 		msg.auth_user.id | ||||||
| 	); | 	); | ||||||
| 	threads = await Promise.all(threads.rows.map(async thread => { |  | ||||||
| 		Object.assign(thread, vybe.threads[thread.id]); |  | ||||||
| 		thread.permissions = await check_permission(msg.auth_user.id, thread.id); |  | ||||||
| 		return thread; |  | ||||||
| 	})); |  | ||||||
| 	return respond({ | 	return respond({ | ||||||
| 		success: true, | 		success: true, | ||||||
| 		threads | 		threads: await Promise.all(threads.rows.map(async row => { | ||||||
|  | 			let thread = {}; | ||||||
|  | 			Object.assign(thread, vybe.threads[row.id]); | ||||||
|  | 			thread.permissions = await check_permission(msg.auth_user.id, row.id); | ||||||
|  | 			thread.permissions.public = row.value === 'true'; | ||||||
|  | 			return thread; | ||||||
|  | 		})) | ||||||
| 	}); | 	}); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -213,8 +215,7 @@ async function get_thread(msg, respond) { | ||||||
| 	const permissions = await db.query( | 	const permissions = await db.query( | ||||||
| 		`select type, user, permission, value, mutable
 | 		`select type, user, permission, value, mutable
 | ||||||
| 		from permission where thread = ?`,
 | 		from permission where thread = ?`,
 | ||||||
| 		msg.thread | 		msg.thread); | ||||||
| 	); |  | ||||||
| 	for (let permission of permissions.rows) { | 	for (let permission of permissions.rows) { | ||||||
| 		const member = members[permission.user]; | 		const member = members[permission.user]; | ||||||
| 		if (member) | 		if (member) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue