forgejo/web_src/js
zeripath 3c4388f668
Re-fix #12095 again (#12138)
Unfortunately some of the suggested changes to #12095 introduced
bugs which due to caching behaviour of sharedworkers were not caught
on simple tests.

These are as follows:

* Changing from simple for loop to use includes here:

```js
  register(port) {
    if (!this.clients.includes(port)) return;

    this.clients.push(port);

    port.postMessage({
      type: 'status',
      message: `registered to ${this.url}`,
    });
  }
```

The additional `!` prevents any clients from being added and should
read:

```js
    if (this.clients.includes(port)) return;
```

* Dropping the use of jQuery `$(...)` selection and using DOM
`querySelector` here:

```js
async function receiveUpdateCount(event) {
  try {
    const data = JSON.parse(event.data);

    const notificationCount = document.querySelector('.notification_count');
    if (data.Count > 0) {
      notificationCount.classList.remove('hidden');
    } else {
      notificationCount.classList.add('hidden');
    }

    notificationCount.text() = `${data.Count}`;
    await updateNotificationTable();
  } catch (error) {
    console.error(error, event);
  }
}
```

Requires that `notificationCount.text()` be changed to use `textContent`
instead.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-07-05 01:04:00 +03:00
..
components Insert ui divider directly in templates instead of from inside heatmap vue component (#11508) 2020-05-19 21:24:14 +01:00
features Re-fix #12095 again (#12138) 2020-07-05 01:04:00 +03:00
markdown Shorten markdown heading anchors links (#11903) 2020-06-26 21:04:22 +08:00
standalone Reorganize frontend files and tooling (#10168) 2020-02-07 18:09:30 +01:00
vendor Fix gitgraph branch continues after merge (#12044) 2020-06-25 14:37:28 +03:00
index.js Move EventSource to SharedWorker (#12095) 2020-07-03 10:55:36 +01:00
jquery.js Upgrade jQuery to 3.5.0, remove jQuery-Migrate, fix deprecations (#11055) 2020-04-18 18:46:29 -04:00
publicpath.js Fix webpack chunk loading with STATIC_URL_PREFIX (#11526) 2020-05-20 23:33:31 +01:00
serviceworker.js Fix serviceworker output file and misc improvements (#11562) 2020-05-24 08:36:40 +01:00
utils.js Move tributejs to npm/webpack (#11497) 2020-05-20 22:00:43 -04:00