Commit graph

317 commits

Author SHA1 Message Date
Ed Sanders 6a17f6121c Move reply widget controlling logic to CommentController
Some of what happens when you click reply happens in
CommentController (in #save) and some error handling
happens in ReplyWidget (in #onReplyClick).

Move most of the logic to CommenController.

Change-Id: Ib6208c0b8d2ddbbcf08adfcca7875ab8b026f598
2024-08-06 09:44:27 -05:00
Ed Sanders a86897f890 Comment thanking
Bug: T249893
Change-Id: I64f7abc26bfc3e7b226340934a637a555edf754f
2024-05-28 17:47:09 +02:00
Ed Sanders 177639f5be Use Array#push instead of Array#concat
Change-Id: I605e726fce1cf1acf39ffdcfe8c7cd51c032a372
2024-05-24 17:28:37 +00:00
Ed Sanders ea5639b20b ESLint: Enforce prefer-const
Change-Id: I5985d1b532988bb3b71ff1aa24eae57ac2e1b9c5
2024-05-24 16:50:13 +01:00
Ed Sanders dda9227947 ESLint: Manually fix remaining no-var violations
Change-Id: I4474bd0205e7a1ed8e60147e52675e3e0b93ccd9
2024-05-24 16:50:11 +01:00
Ed Sanders ca5157156a ESLint: Autofix no-var rule
Leave rule off for now as manual fixes are required.

Also temporarily disable prefer-const rule as that
will also require some manual fixes.

Change-Id: I8c3478f26f51287acb943bd38c9c1020c06b9f39
2024-05-24 16:49:36 +01:00
jenkins-bot 5689650a6a Merge "Replace $.extend with Object.assign" 2024-05-02 21:42:02 +00:00
Ed Sanders 1e0aa2171f Replace $.extend with Object.assign
Change-Id: Id559ab68451a1d767e92ed17b1ef0832a5f243af
2024-05-02 16:49:43 +01:00
Ed Sanders 2dd73f935c JSDoc: {Mixed} -> {any}
Change-Id: I78bdc1ec8767dca05e979d8c6ebfed72573acc6f
2024-05-02 10:36:24 +01:00
Bartosz Dziewoński d4c5aebd8f Prefer short arrow functions
When an arrow function body contains just a single `return` statement,
the braces can be omitted.

(Changes are mostly made by `grunt eslint --fix`, with only some line
breaks added by hand.)

Change-Id: I37f259f87085c8d20ed09cfa58a8456dd36cdc38
2024-04-20 00:08:51 +02:00
Ed Sanders f509f91c71 Remove unnecessary IIFE
Change-Id: I1f23cd134d830afdf4d6afee5f1a399743c9eaa6
2024-04-19 12:34:28 +01:00
Ed Sanders a74c00ba8c Prefer arrow functions for callbacks
This allows us to remove our `this` bindings.

Change-Id: Ie8c8c38d36af8a033b5181870c39f8981a57b939
2024-04-19 12:34:23 +01:00
David Lynch ebc884e217 Also don't check for moved topics on fragments starting with !/
Similar reasoning for our existing filter on just `/`; it's only really
used in state routing.

Bug: T361322
Change-Id: Ibcf1a58a884b953003012640041471d3bb5c9450
2024-03-29 10:07:43 -05:00
jenkins-bot ab9aae8172 Merge "Pass through dtenable from main request query string" 2024-03-25 20:16:46 +00:00
Ed Sanders 5957ac55df Pass through dtenable from main request query string
Instead of passing dtenable=1 unconditionally for API requests.

Bug: T360863
Change-Id: I42c651558d95a88eaf6006b6509caa4e41df8464
2024-03-25 18:26:53 +00:00
David Lynch 5276729d3e Add #top to the ignore list for checking for moved topics
Top is in the WHATWG spec as a magic value that always navigates to the
top of the document.

There used to be a #top element in pre-Vector2022 skins, and it's in
fairly wide use on some wikis in signatures and via gadgets, so many
links exist that point to it.

Bug: T360274
Change-Id: Ia12464239ab2cdc428c570d0cf5df1c0d1780b7a
2024-03-22 22:01:17 -05:00
jenkins-bot 63dd90a8dc Merge "Fix collapsed sections when recovering autosave on mobile, take 3" 2024-03-07 17:36:12 +00:00
Bartosz Dziewoński a9966234ac Fix collapsed sections when recovering autosave on mobile, take 3
We need to more carefully wait for mobile section toggling to happen.
Follow-up to 3957d7ac25.

Bug: T338920
Change-Id: I1bd31483c5be9428075f07494e89b06f19f8bf23
2024-02-28 04:43:59 +01:00
jenkins-bot 545d17d2c9 Merge "Replace spaces in link fragments before searching for topics/comments" 2024-02-26 19:21:11 +00:00
Ed Sanders 16e308119f Replace spaces in link fragments before searching for topics/comments
MediaWiki should never generate links like this, but users or 3rd
party tools probably create them accidentally quite regularly, and
we do a similar thing with Title normalisation.

Change-Id: Ia467f422578bcb9b4d3fb8feab0b85f4b6436f7e
2024-02-26 18:59:00 +00:00
jenkins-bot 26abd2383d Merge "Fix collapsed sections when recovering autosave on mobile, take 2" 2024-02-08 16:38:22 +00:00
jenkins-bot 6816c15a03 Merge "Fix exceptions on weirdly encoded URLs" 2024-02-05 22:22:02 +00:00
Bartosz Dziewoński 3957d7ac25 Fix collapsed sections when recovering autosave on mobile, take 2
Follow-up to 8a8c7270cf.

I think this wasn't working becase we were doing it in the wrong
order (reply tool initialization would disable toggling section
state before toggler toggled it open).

Bug: T338920
Change-Id: I7ed3d5c149ddb3d33cb67010f032c63e175687f2
2024-02-04 00:21:45 +01:00
Bartosz Dziewoński f7a8ba08fb Ignore transcluded items when finding permalinks
* Keep the information about this in the API result, which we were
  previously omitting
* Use it instead of duplicating the logic client-side

Bug: T356131
Change-Id: I7e7342e9d94a171b5ef56e646871c18c8c39c44c
2024-02-04 00:07:37 +01:00
Bartosz Dziewoński 1bb3b597ec Fix exceptions on weirdly encoded URLs
`decodeURI( fragment )` can throw if the fragment isn't correctly
encoded – e.g. when it's just '#%'.

Use mw.util.percentDecodeFragment() instead, which uses a more
resilient algorithm.

Change-Id: I8447771ad2ae33da52b71d4127981dd8a2018a7d
2024-02-03 23:48:54 +01:00
Ed Sanders df7d101cd2 Use decodeURI for comment ID searches as well as heading searches
Bug: T356199
Change-Id: I8d366c706692caf89a2af9f11c14a9aad9422b7c
2024-02-02 17:34:26 +00:00
David Lynch 7b941aae1c Add an exception for ConvenientDiscussions-style permalinks
Bug: T349653
Change-Id: I775774084bb8abf2bc99475b426d581bed306306
2024-01-30 16:44:30 -06:00
David Lynch c4bbf8756a decodeURI fragments before sending them to discussiontoolsfindcomment
Section titles containing non-ASCII characters were being passed through
URL-encoded, resulting in no results being found.

Bug: T356199
Change-Id: Iac56ee434a37baf3d170aec992d2f2d8679b6f1f
2024-01-30 14:14:18 -06:00
David Lynch d74eccad34 Comment-not-found toast not showing when enablePermalinksFrontend==false
results[ 0 ] would be undefined, causing a later JS error before the
toast could be shown.

Bug: T355165
Change-Id: Ia591a1e4db0acfa377201c355938a32f680393ce
2024-01-16 11:13:18 -06:00
Ed Sanders 4f217f4dab controller: Use replyWidgetPromise when opening new topic tool
This prevents an exception being thrown if you open the
new topic tool when a reply widget is still loading.

Change-Id: I17da48ddf91394d05cc82613ce5517f1e176750b
2024-01-05 16:20:30 +00:00
Ed Sanders 811dce7bf7 CommentController#showAndFocus: Use replyWidgetPromise
We shouldn't assume callers of this method have waited
for the replyWidget to be built.

Bug: T354292
Change-Id: Ic66b4f04b8786b07f520e329adda37efcf498dad
2024-01-05 15:26:19 +00:00
David Lynch 95121b7364 Stop comment-not-found notification always showing when requestedSince
`TEST && false || true` is always true regardless of `TEST`, we want
`TEST && (false || true)` instead.

Bug: T353568
Change-Id: I72fa6b87f43a9d8439883dfedc35fe82974b35de
2023-12-16 09:20:19 -06:00
Ed Sanders c82783a5b6 Find a heading by title in archives
* Looks for heading IDs matching "h-<heading text>-%" that once
  existed on the target page.
* For such IDs, finds where those items currently exist,
  presumably in an archive.

Pros:
* Doesn't need to know anything about the local wiki's archiving
  conventions, so can be deployed universally.

Cons:
* ID conflicts will return matches in unrelated archives, e.g.
  MassMessages.

Bug: T349653
Change-Id: Ie94efd0503e9f4689d3421babe445f9f4e2b4fb7
2023-12-06 18:39:28 +00:00
Ed Sanders 4733eb0362 Show new location of missing comments in notification
Bug: T304579
Change-Id: I5c9229a25875f0bb73c2a4dbfd0e1ac25f9c893e
2023-12-06 18:39:27 +00:00
David Lynch b3a838fc38 Notify when we can't find a comment from a reply-link
This requires something like an invalid timestamp, to produce a reply
link whose associated comment ID is going to not be findable.

Bug: T350633
Change-Id: Ib50c11096b9af9961b74309b60524a4b986e04aa
2023-11-07 11:59:03 -06:00
jenkins-bot f669b6365d Merge "Don't clear comment highlight when clicking on another link" 2023-10-13 17:44:19 +00:00
Ed Sanders 185396a8e5 Merge ReplyWidget[Plain/Visual] modules
Only a fraction of a percentage of users are still using
ReplyWidgetPlain, and keeping these modules separate:
* Adds to code complexity
* Adds to ResourceLoader module bloat
* Causes bugs when we use VE dependencies in the
  core ReplyWidget class

The disadvantage is that ReplyWidgetPlain will now be
loading all of the VE dependencies, but this will make
switching to visual mode faster.

Bug: T348834
Change-Id: Ifb0cfd43fdab761c3321ad01fa9fefca26473f86
2023-10-13 11:58:12 +01:00
Kosta Harlan 60bcf84dbb overflow menu: Factor code into its own file
Why:

- We'll reuse this functionality on desktop, so it makes sense to
  extract it to a standalone file

What:

- Remove relevant code from mobile.js and place in overflowMenu.js

Bug: T342251
Change-Id: I98f1253e8d6db31c1f71203b50911b6f1b92778b
2023-10-12 06:03:11 +00:00
Kosta Harlan c6c7dd2fb0 overflow menu: Add hooks for registering and interacting with items
Why:

- We want to allow extensions to register interactive menu items in the
  overflow menu.

What:

- Create a PHP hook to allow extensions to provide menu items
  for rendering in the overflow menu
  - The hook allows for registering resource loader modules required by
    the menu item
  - The hook passes in some contextual information, like the thread
    item data, context source object, and if the page is editable
- Create a JS hook that fires when a user selects one of the menu items
- Example implementation: Ie9afbedb4f24cbd75eb48bb21dc9f6d8d732d853

Misc:

- Remove b/c code that existed to handle a transitional period where
  JSON encoded overflow menu data did not necessarily exist in the
  parser cache
- Rename code instances of ellipsis button / data / menu to refer to
  "overflow menu"
  - Some renames will have to wait until parser cache is updated; these
    are noted with TODOs

Bug: T342251
Change-Id: I5f2a51791f8ba7619d1399a4b93111e9bb44e172
2023-10-05 15:50:33 +01:00
Ed Sanders 58cb277ced Factor out permalink code into separate file
Change-Id: Ib56a0b9766529f517ae8c5f743f891b06f3cf690
2023-10-05 10:55:00 +01:00
Bartosz Dziewoński d27d9ab7b0 Don't clear comment highlight when clicking on another link
When the user clicks anywhere on the page after following a permalink
(e.g. from a notification), we would remove the comment highlight and
the hash from the URL. Don't do it if the click is on another link:
this avoids inserting extra history entries when clicking on several
permalinks in a row.

Change-Id: I5d77dae4608f74b2be09b9cb92e39a8662529a9f
2023-10-03 22:07:12 +02:00
Bartosz Dziewoński efceaaa2ad Fix temp user popup appearing on every new page creation
Follow-up to c0f5a95504.
I missed that this code path can also be reached when
a temp user has not in fact been created.

Bug: T345569
Change-Id: Ia37760c674074b12baa17d842fa4f4d95ca20c5e
2023-09-04 17:17:06 +02:00
Bartosz Dziewoński c0f5a95504 Fix showing temp user popup after page reload
Bug: T344879
Change-Id: I1bb86468c27d4fbbd55ebcdc81ec841fbfeeb952
2023-08-24 16:09:25 +00:00
Ed Sanders 2f280e11c4 Wait for mobile.init before doing initial highlightTargetComment
Change-Id: If0e4f1d0e917a058eae26fd4848382ea1ac5241a
2023-08-15 17:04:17 +01:00
Bartosz Dziewoński 90f8fe5ec1 Reload page or redirect when saving an edit creates a temp account
Depends-On: I6cdc014fb39d35ce1f091b53dc3a9c4a3c95f9e9
Depends-On: I01e13ce1ebab462eeb0ba3847d4205a88965a127
Bug: T338002
Change-Id: I768e4fa2030d781bbc65428371bda17a87bd6a42
2023-07-10 22:55:58 +00:00
jenkins-bot 6de3603990 Merge "ApiDiscussionToolsEdit: Allow not returning the new revision content" 2023-06-22 21:31:32 +00:00
jenkins-bot 7c0f099529 Merge "Redo wrapper for localStorage integration" 2023-06-19 15:54:16 +00:00
Bartosz Dziewoński f7d98d7690 Redo wrapper for localStorage integration
I think the issues in T329299 are caused by partially autosaved
comments. We store data in multiple localStorage keys, and if some of
them are stored but others are not (due to exceeding storage quota),
our code can't handle the inconsistent state.

We already have a wrapper around localStorage that tries to cover up
these issues. Change it so that all values specific to an instance of
a reply tool are stored under one localStorage key. This ensures that
all updates consistently succeed or fail, with no partially stored
state.

One of the reasons we haven't done this is because this requires the
whole data to be serialized to JSON every time, but our experience
with VE change 4355d697aa shows that this is fast enough.

Extra changes:
* Remove storagePrefix, now redundant
* Remove use of createConflictableStorage, now redundant
* Prefix the key with 'mw' as advised by mw.storage documentation
* Use ES6 syntax for the new code (just for fun)
* Use consistent expiry (T339042)

Bug: T329299
Change-Id: I347115f7187fd7d6afd9c6f368441e262154233b
2023-06-19 16:45:08 +02:00
jenkins-bot 3a796a228c Merge "Remove a mobile hack for post-edit messages" 2023-06-15 16:33:43 +00:00
Ed Sanders 8a8c7270cf Set URL fragment when recovering auto-save on mobile
This triggers Toggler.js in MF to open the section, which
may not be stored in sessionStorage, as DT can recover
from localStorage.

Bug: T338920
Change-Id: I695e2d423b5159ef4cdcefc0f4d4d0a05f46879b
2023-06-14 18:04:19 +01:00