mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Use fetch helpers instead of fetch (#27026)
WIP because: - [x] Some calls set a `content-type` but send no body, can likely remove the header - [x] Need to check whether `charset=utf-8` has any significance on the webauthn calls, I assume not as it is the default for json content. - [x] Maybe `no-restricted-globals` is better for eslint, but will require a lot of duplication in the yaml or moving eslint config to a `.js` extension. - [x] Maybe export `request` as `fetch`, shadowing the global.
This commit is contained in:
		| @@ -1,6 +1,5 @@ | ||||
| import $ from 'jquery'; | ||||
|  | ||||
| const {csrfToken} = window.config; | ||||
| import {POST} from '../../modules/fetch.js'; | ||||
|  | ||||
| export function initCompReactionSelector($parent) { | ||||
|   $parent.find(`.select-reaction .item.reaction, .comment-reaction-button`).on('click', async function (e) { | ||||
| @@ -12,15 +11,8 @@ export function initCompReactionSelector($parent) { | ||||
|     const reactionContent = $(this).attr('data-reaction-content'); | ||||
|     const hasReacted = $(this).closest('.ui.segment.reactions').find(`a[data-reaction-content="${reactionContent}"]`).attr('data-has-reacted') === 'true'; | ||||
|  | ||||
|     const res = await fetch(`${actionUrl}/${hasReacted ? 'unreact' : 'react'}`, { | ||||
|       method: 'POST', | ||||
|       headers: { | ||||
|         'content-type': 'application/x-www-form-urlencoded', | ||||
|       }, | ||||
|       body: new URLSearchParams({ | ||||
|         _csrf: csrfToken, | ||||
|         content: reactionContent, | ||||
|       }), | ||||
|     const res = await POST(`${actionUrl}/${hasReacted ? 'unreact' : 'react'}`, { | ||||
|       data: new URLSearchParams({content: reactionContent}), | ||||
|     }); | ||||
|  | ||||
|     const data = await res.json(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 silverwind
					silverwind