Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/60692
Change subject: Story 358: Persistent watchlist view
......................................................................
Story 358: Persistent watchlist view
When loading watchlist set user preferences that are taken into
account when creating link on menu and watchlist header to make
the view persistent
Change-Id: I289e7303261188a281f7d36212b4fdfd1bb9ad2e
---
M includes/skins/SkinMobileBase.php
M includes/specials/SpecialMobileWatchlist.php
2 files changed, 25 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/92/60692/1
diff --git a/includes/skins/SkinMobileBase.php
b/includes/skins/SkinMobileBase.php
index 21451cb..8f5c142 100644
--- a/includes/skins/SkinMobileBase.php
+++ b/includes/skins/SkinMobileBase.php
@@ -145,11 +145,25 @@
{$licenseText}<span> | {$termsUse}</span>
HTML;
+ // user specific configurations
+ $user = $this->getUser();
+ $watchlistQuery = array();
+ if ( $user ) {
+ $view = $user->getOption( 'mf-watchlist-view', false );
+ $filter = $user->getOption( 'mf-watchlist-filter',
false );
+ if ( $view ) {
+ $watchlistQuery['watchlistview'] = $view;
+ }
+ if ( $filter ) {
+ $watchlistQuery['filter'] = $filter;
+ }
+ }
+
$tpl->set( 'mobile-switcher', $switcherHtml );
$tpl->set( 'mobile-notice', $noticeHtml );
$tpl->set( 'mainPageUrl', Title::newMainPage()->getLocalUrl() );
$tpl->set( 'randomPageUrl', SpecialPage::getTitleFor(
'Randompage' )->getLocalUrl() );
- $tpl->set( 'watchlistUrl', SpecialPage::getTitleFor(
'Watchlist' )->getLocalUrl() );
+ $tpl->set( 'watchlistUrl', SpecialPage::getTitleFor(
'Watchlist' )->getLocalUrl( $watchlistQuery ) );
$tpl->set( 'searchField', $this->getRequest()->getText(
'search', '' ) );
$tpl->set( 'loggedin', $this->getUser()->isLoggedIn() );
$this->loggedin = $this->getUser()->isLoggedIn();
diff --git a/includes/specials/SpecialMobileWatchlist.php
b/includes/specials/SpecialMobileWatchlist.php
index b0a5966..96e33eb 100644
--- a/includes/specials/SpecialMobileWatchlist.php
+++ b/includes/specials/SpecialMobileWatchlist.php
@@ -15,7 +15,6 @@
function execute( $par ) {
wfProfileIn( __METHOD__ );
-
$ctx = MobileContext::singleton();
$this->usePageImages = !$ctx->imagesDisabled() && defined(
'PAGE_IMAGES_INSTALLED' );
$this->getOutput()->setProperty( 'mobile.htmlHeader',
$this->getWatchlistHeader() );
@@ -25,7 +24,7 @@
$output->addModuleStyles( 'mobile.watchlist.styles' );
$output->addModules( 'mobile.watchlist.scripts' );
$req = $this->getRequest();
- $view = $req->getVal( 'watchlistview', 'a-z' );
+ $view = $req->getVal( 'watchlistview', $user->getOption(
'mf-watchlist-view', 'a-z' ) );
$this->fromPageTitle = Title::newFromText( $req->getVal(
'from', false ) );
$recentChangesView = ( $view === 'feed' ) ? true : false;
@@ -41,15 +40,20 @@
}
if ( $recentChangesView ) {
- $this->filter = $this->getRequest()->getVal( 'filter',
'all' );
+ $this->filter = $this->getRequest()->getVal( 'filter',
$user->getOption( 'mf-watchlist-filter', 'all' ) );
$this->showRecentChangesHeader();
$res = $this->doFeedQuery();
$this->showFeedResults( $res );
+ $user->setOption( 'mf-watchlist-filter', $this->filter
);
} else {
$this->filter = $this->getRequest()->getVal( 'filter',
'articles' );
$res = $this->doListQuery();
$this->showListResults( $res );
}
+
+ // make this sticky
+ $user->setOption( 'mf-watchlist-view', $view );
+ $user->saveSettings();
wfProfileOut( __METHOD__ );
}
@@ -88,6 +92,7 @@
}
protected function getWatchlistHeader() {
+ $user = $this->getUser();
$cur = $this->getRequest()->getVal( 'watchlistview', 'a-z' );
$sp = SpecialPage::getTitleFor( 'Watchlist' );
$attrsList = array(
@@ -115,13 +120,14 @@
wfMessage( 'mobile-frontend-watchlist-a-z'
)->text(),
$attrsList,
array(
- 'watchlistview' => 'a-z'
+ 'watchlistview' => 'a-z',
)
) .
Linker::link( $sp,
wfMessage( 'mobile-frontend-watchlist-feed'
)->text(),
$attrsFeed,
array(
+ 'filter' => $user->getOption(
'mf-watchlist-filter', 'all' ),
'watchlistview' => 'feed'
)
) .
--
To view, visit https://gerrit.wikimedia.org/r/60692
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I289e7303261188a281f7d36212b4fdfd1bb9ad2e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits