mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Fix some incorrect async functions, improve frontend document. (#17597)
This commit is contained in:
		@@ -3,21 +3,22 @@ const {appSubUrl, csrfToken, notificationSettings} = window.config;
 | 
			
		||||
let notificationSequenceNumber = 0;
 | 
			
		||||
 | 
			
		||||
export function initNotificationsTable() {
 | 
			
		||||
  $('#notification_table .button').on('click', async function () {
 | 
			
		||||
    const data = await updateNotification(
 | 
			
		||||
      $(this).data('url'),
 | 
			
		||||
      $(this).data('status'),
 | 
			
		||||
      $(this).data('page'),
 | 
			
		||||
      $(this).data('q'),
 | 
			
		||||
      $(this).data('notification-id'),
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    if ($(data).data('sequence-number') === notificationSequenceNumber) {
 | 
			
		||||
      $('#notification_div').replaceWith(data);
 | 
			
		||||
      initNotificationsTable();
 | 
			
		||||
    }
 | 
			
		||||
    await updateNotificationCount();
 | 
			
		||||
  $('#notification_table .button').on('click', function () {
 | 
			
		||||
    (async () => {
 | 
			
		||||
      const data = await updateNotification(
 | 
			
		||||
        $(this).data('url'),
 | 
			
		||||
        $(this).data('status'),
 | 
			
		||||
        $(this).data('page'),
 | 
			
		||||
        $(this).data('q'),
 | 
			
		||||
        $(this).data('notification-id'),
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      if ($(data).data('sequence-number') === notificationSequenceNumber) {
 | 
			
		||||
        $('#notification_div').replaceWith(data);
 | 
			
		||||
        initNotificationsTable();
 | 
			
		||||
      }
 | 
			
		||||
      await updateNotificationCount();
 | 
			
		||||
    })();
 | 
			
		||||
    return false;
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
@@ -104,8 +105,8 @@ export function initNotificationCount() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const fn = (timeout, lastCount) => {
 | 
			
		||||
    setTimeout(async () => {
 | 
			
		||||
      await updateNotificationCountWithCallback(fn, timeout, lastCount);
 | 
			
		||||
    setTimeout(() => {
 | 
			
		||||
      const _promise = updateNotificationCountWithCallback(fn, timeout, lastCount);
 | 
			
		||||
    }, timeout);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user