Page MenuHomePhabricator

Replace mobile.toast with mw.notification?
Closed, ResolvedPublic


It seems, that mobile.toast (our primary module for generating notifications in MobileFrontend) looks very similar to mw.notification notifications (thanks to @Jdlrobson). This task should be a reminder (for me) and a question into the round: wouldn't it make sense to kill one of these systems to create notifications (e.g. mobile.toast) and use only one of them? What blocks us doing that (e.g. pending toasts for edits, btw. it's only used by mobile.editor as far as I know, and desktop does a similar thing, maybe we can merge these methods, too).

Event Timeline

Florian raised the priority of this task from to Needs Triage.
Florian updated the task description. (Show Details)
Florian added a project: MobileFrontend.
Florian added subscribers: Florian, Jdlrobson.
Florian set Security to None.

In principle it sounds good.

That said size difference mediawiki.notifications is double the size (5.5kb compared with "2.8 kB" for mobile toast)
What does this module do that mobile toast doesn't?
Is it worth the extra payload?
Can we reduce the size of the payload?

Once we can answer the above questions I think we can do this.

Jdlrobson triaged this task as Medium priority.Oct 26 2015, 3:59 PM

What does this module do that mobile toast doesn't?

AFAICT it seems to be the auto-hide handling part (start/pause/stop and so on) which takes some of the size, and general styling (parts of what mobile.toast has in View.js is in mediawiki.notification).

Is it worth the extra payload?

I would say: Yes :) It could be useful in mobile, too, to have an auto hide handling code, and it would make to use core methods for notifications (e.g. to use them when the whole mobile part moves to core).

Can we reduce the size of the payload?

Adhoc I don't see much space without removing functionality (which is maybe used in other functions, too). I would, btw., suggest to do the same as in core: Use a small helper module, like mediawiki.notify, which is really small and it's only task is to load the notification module only, if it's needed (so that all notifications goes through this).

mediawiki.notify has a size of (compressed) 263 Bytes (maybe it increases a bit, depends on how we implement the pending toasts), but that would effectively reduce the payload for the most pages a lot.

If toasts are replaced by mw.notification, I suppose the only code remaining in MobileFronted would be to show pending toasts and the helper module that will call mw.notification, isn't it?

Change 258969 had a related patch set uploaded (by Sumit):
MobileFrontend mw.notification instead of toast

Change 258969 merged by jenkins-bot:
MobileFrontend mw.notification instead of toast