aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/notification.js
Commit message (Collapse)AuthorAgeFilesLines
* Fix notification list bugs (#25781)wxiaoguang2023-07-091-1/+1
| | | | | | | | | Fix #25627 1. `ctx.Data["Link"]` should use relative URL but not AppURL 2. The `data-params` is incorrect because it doesn't contain "page". JS can simply use "window.location.search" to construct the AJAX URL 3. The `data-xxx` and `id` in notification_subscriptions.tmpl were copied&pasted, they don't have affect.
* Rework notifications list (#24812)silverwind2023-05-251-0/+24
| | | | | | | | | | | - Replace `<table>` with flexbox - Add issue modification time and issue number - Remove big title - Replace tabs with menu items - Add clicked item deletion on back button cache restoration --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move helpers to be prefixed with `gt-` (#22879)zeripath2023-02-131-3/+3
| | | | | | | | | | | | | | | | | | | | As discussed in #22847 the helpers in helpers.less need to have a separate prefix as they are causing conflicts with fomantic styles This will allow us to have the `.gt-hidden { display:none !important; }` style that is needed to for the reverted PR. Of note in doing this I have noticed that there was already a conflict with at least one chroma style which this PR now avoids. I've also added in the `gt-hidden` style that matches the tailwind one and switched the code that needed it to use that. Signed-off-by: Andrew Thornton <art27@cantab.net> --------- Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enable contenthash in filename for dynamic assets (#20813)silverwind2022-08-231-2/+2
| | | | | This should solve the main problem of dynamic assets getting stale after a version upgrade. Everything not affected will use query-string based cache busting, which includes files loaded via HTML or worker scripts.
* Fix the JS error "EventSource is not defined" caused by some non-standard ↵wxiaoguang2022-08-031-24/+23
| | | | | | | browsers (#20584) * fall back to periodic poller Co-authored-by: silverwind <me@silverwind.io>
* Never use /api/v1 from Gitea UI Pages (#19318)Lunny Xiao2022-04-071-1/+1
| | | | | | | | | | | | | Reusing `/api/v1` from Gitea UI Pages have pros and cons. Pros: 1) Less code copy Cons: 1) API/v1 have to support shared session with page requests. 2) You need to consider for each other when you want to change something about api/v1 or page. This PR moves all dependencies to API/v1 from UI Pages. Partially replace #16052
* Use explicit jQuery import, remove unused eslint globals (#18435)silverwind2022-01-281-1/+2
| | | | | - Don't rely on globals (window.$) for jQuery import - Remove eslint globals no longer in use
* Fix some incorrect async functions, improve frontend document. (#17597)wxiaoguang2021-11-121-17/+18
|
* Improve async/await usage, and sort init calls in `index.js` (#17386)wxiaoguang2021-11-091-2/+2
| | | | * clean up async/await, and sort init calls in `index.js * use `const _promise` to indicate that we do not need await an async function
* Frontend refactor, PascalCase to camelCase, remove unused code (#17365)wxiaoguang2021-10-211-14/+14
| | | | | * Frontend refactor, PascalCase to camelCase, remove unused code * fix
* Update JS dependencies (#16708)silverwind2021-08-171-2/+2
| | | | | | | | | | | | | | * Update JS dependencies - Update all JS dependencies - Adapt to recent webpack changes - Add new lint rules and fix issues - Regenerate SVGs and update svgo api usage Fixes: https://github.com/go-gitea/gitea/pull/16492 * adapt jest config and sort keys Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Update notification table with only latest data (#16445)zeripath2021-07-171-4/+12
| | | | | | | | | | When marking notifications read the results may be returned out of order or be delayed. This PR sends a sequence number to gitea so that the browser can ensure that only the results of the latest notification change are shown. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
* Fix handling of logout event (#15323)zeripath2021-04-081-1/+1
| | | | | | | It appears that there is a slight bug in the handling of the data of logout event - the javascript should be testing the data field of the data field for the logout instruction. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Drop the event source if we are unauthorized (#15275)zeripath2021-04-041-0/+5
| | | | | | | | | A previous commit that sent unauthorized if the user is unauthorized simply leads to the repeated reopening of the eventsource. # This PR changes the event returned to tell the client to close the eventsource and thus prevents the repeated reopening. Signed-off-by: Andrew Thornton <art27@cantab.net>
* Update JS dependencies and webpack (#14118)silverwind2020-12-271-37/+35
| | | | | | | | | | | | | | | | | | * Update JS dependencies - Update all JS dependencies - Adapt webpack config for version 5 - Update to Less 4.0, adapting usage of removed mixin syntax - Enable new ESLint rules and fix discovered issues * update license-webpack-plugin to fix missing licenses * update license-webpack-plugin once more to get webpack into the license output * switch to license-checker-webpack-plugin again for performance * update deps again Co-authored-by: Lauris BH <lauris@nix.lv>
* Re-fix #12095 again (#12138)zeripath2020-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Bugfix for shared event source (#12129)zeripath2020-07-041-11/+6
| | | | | | | | 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> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Move EventSource to SharedWorker (#12095)zeripath2020-07-031-29/+68
| | | | | | | | | | | | | 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>
* Close EventSource before unloading the page (#11539)silverwind2020-05-221-0/+3
| | | | Should eliminate a error in the Firefox console regarding the connection being interrupted while the page was loading.
* Add EventSource support (#11235)zeripath2020-05-071-11/+48
| | | | | | If the browser supports EventSource switch to use this instead of polling notifications. Signed-off-by: Andrew Thornton art27@cantab.net
* Use AJAX for notifications table (#10961)zeripath2020-04-241-0/+110
* Use AJAX for notifications table Signed-off-by: Andrew Thornton <art27@cantab.net> * move to separate js Signed-off-by: Andrew Thornton <art27@cantab.net> * placate golangci-lint Signed-off-by: Andrew Thornton <art27@cantab.net> * Add autoupdating notification count Signed-off-by: Andrew Thornton <art27@cantab.net> * Fix wipeall Signed-off-by: Andrew Thornton <art27@cantab.net> * placate tests Signed-off-by: Andrew Thornton <art27@cantab.net> * Try hidden Signed-off-by: Andrew Thornton <art27@cantab.net> * Try hide and hidden Signed-off-by: Andrew Thornton <art27@cantab.net> * More auto-update improvements Only run checker on pages that have a count Change starting checker to 10s with a back-off to 60s if there is no change Signed-off-by: Andrew Thornton <art27@cantab.net> * string comparison! Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @silverwind Signed-off-by: Andrew Thornton <art27@cantab.net> * add configurability as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> * Add documentation as per @6543 Signed-off-by: Andrew Thornton <art27@cantab.net> * Use CSRF header not query Signed-off-by: Andrew Thornton <art27@cantab.net> * Further JS improvements Fix @etzelia update notification table request Fix @silverwind comments Co-Authored-By: silverwind <me@silverwind.io> Signed-off-by: Andrew Thornton <art27@cantab.net> * Simplify the notification count fns Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>