You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/modules
zeripath e46dbec294
Move EventSource to SharedWorker (#12095) (#12130)
* Move EventSource to SharedWorker (#12095)

Backport #12095

Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.

Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating

Fix #11978

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>

* Bugfix for shared event source

For some reason our eslint configuration is not working correctly
and a bug has become apparent when trying to backport this to 1.12.

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Re-fix #12095 again

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>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
5 years ago
..
analyze Exclude generated files from language statistics (#11653) (#11670) 5 years ago
auth Use google/uuid to instead satori/go.uuid (#11943) (#11946) 5 years ago
avatar Improve handling of non-square avatars (#7025) 6 years ago
base Add gitea-vet (#10948) 5 years ago
cache make avatar lookup occur at image request (#10540) 5 years ago
charset deps: update and fix chardet import (#9351) 5 years ago
context [API] on 500 error only show message if gitea in dev mode (#11641) (#11753) 5 years ago
convert Honor DEFAULT_PAGING_NUM for API (#11805) (#11813) 5 years ago
cron Refactor Cron and merge dashboard tasks (#10745) 5 years ago
emoji Update emoji dataset with skin tone variants (#11678) (#11763) 5 years ago
eventsource Move EventSource to SharedWorker (#12095) (#12130) 5 years ago
generate Add gitea-vet (#10948) 5 years ago
git Ensure BlameReaders close at end of request (#12102) (#12103) 5 years ago
gitgraph Move git graph from models to modules/graph (#9027) 5 years ago
graceful Handle panics that percolate up to the graceful module (#11291) 5 years ago
highlight Add a lot of extension to language mappings for syntax highlights (#7741) 6 years ago
httplib Add golangci (#6418) 6 years ago
indexer Change language statistics to save size instead of percentage (#11681) (#11690) 5 years ago
lfs Support Range header end in lfs (#11314) 5 years ago
log modules/log: remove noop written variables (#10182) 5 years ago
markup Update emoji regex (#11584) (#11679) 5 years ago
metrics Prometheus endpoint (#5256) 6 years ago
migrations Set the base url when migrating from Gitlab using access token or username without password (#11852) (#12104) 5 years ago
notification Add NotifySyncPushCommits to indexer notifier (#11309) 5 years ago
options Rename scripts to build and add revive command as a new build tool command (#10942) 5 years ago
password Add password requirement info on error (#9074) 5 years ago
pprof Add golangci (#6418) 6 years ago
private Upgrade golangci-lint to 1.24.0 (#10894) 5 years ago
process Add gitea-vet (#10948) 5 years ago
public Add serviceworker.js to KnownPublicEntries (#11992) (#11994) 5 years ago
queue Prevent timer leaks in Workerpool and others (#11333) 5 years ago
recaptcha fixed reCAPTCHA URL (#9083) 5 years ago
references Accept punctuation after simple+cross repository issue references (#10091) 5 years ago
repofiles Revert "Avoid 0 new commits messages to be send (#11082)" (#11397) 5 years ago
repository Global default branch setting (#11918) (#11937) 5 years ago
secret Integrate OAuth2 Provider (#5378) 6 years ago
session Prevent (caught) panic on login (#11590) (#11597) 5 years ago
setting Global default branch setting (#11918) (#11937) 5 years ago
ssh log.Fatal on failure to listen to SSH port (#10795) 5 years ago
structs Add option to API to update PullRequest base branch (#11666) (#11796) 5 years ago
sync Fix missing unlock in uniquequeue (#9790) 5 years ago
task Move create/fork repository from models to modules/repository (#9489) 5 years ago
templates Move EventSource to SharedWorker (#12095) (#12130) 5 years ago
test Add Organization Wide Labels (#10814) 5 years ago
timeutil Fix timezone on issue deadline (#11697) (#11784) 5 years ago
upload Fix upload file type check (#7890) 6 years ago
user Add gitea-vet (#10948) 5 years ago
util Prevent timer leaks in Workerpool and others (#11333) 5 years ago
validation [API] Get a single commit via Ref (#10915) 5 years ago
webhook Fix comments webhook panic backport (#12058) 5 years ago