Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14046342
D10113.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D10113.diff
View Options
diff --git a/src/applications/notification/controller/PhabricatorNotificationClearController.php b/src/applications/notification/controller/PhabricatorNotificationClearController.php
--- a/src/applications/notification/controller/PhabricatorNotificationClearController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationClearController.php
@@ -5,6 +5,7 @@
public function processRequest() {
$request = $this->getRequest();
+ $chrono_key = $request->getInt('chronoKey');
$user = $request->getUser();
if ($request->isDialogFormPost()) {
@@ -12,10 +13,11 @@
queryfx(
$table->establishConnection('w'),
- 'UPDATE %T SET hasViewed = 1 WHERE
- userPHID = %s AND hasViewed = 0',
+ 'UPDATE %T SET hasViewed = 1 '.
+ 'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %d',
$table->getTableName(),
- $user->getPHID());
+ $user->getPHID(),
+ $chrono_key);
return id(new AphrontReloadResponse())
->setURI('/notification/');
@@ -23,23 +25,31 @@
$dialog = new AphrontDialogView();
$dialog->setUser($user);
- $dialog->setTitle('Really mark all notifications as read?');
-
- $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
- if ($is_serious) {
- $dialog->appendChild(
- pht(
- 'All unread notifications will be marked as read. You can not '.
- 'undo this action.'));
+ $dialog->addCancelButton('/notification/');
+ if ($chrono_key) {
+ $dialog->setTitle('Really mark all notifications as read?');
+ $dialog->addHiddenInput('chronoKey', $chrono_key);
+
+ $is_serious =
+ PhabricatorEnv::getEnvConfig('phabricator.serious-business');
+ if ($is_serious) {
+ $dialog->appendChild(
+ pht(
+ 'All unread notifications will be marked as read. You can not '.
+ 'undo this action.'));
+ } else {
+ $dialog->appendChild(
+ pht(
+ "You can't ignore your problems forever, you know."));
+ }
+
+ $dialog->addSubmitButton(pht('Mark All Read'));
} else {
- $dialog->appendChild(
- pht(
- "You can't ignore your problems forever, you know."));
+ $dialog->setTitle('No notifications to mark as read.');
+ $dialog->appendChild(pht(
+ 'You have no unread notifications.'));
}
- $dialog->addCancelButton('/notification/');
- $dialog->addSubmitButton(pht('Mark All Read'));
-
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}
diff --git a/src/applications/notification/controller/PhabricatorNotificationListController.php b/src/applications/notification/controller/PhabricatorNotificationListController.php
--- a/src/applications/notification/controller/PhabricatorNotificationListController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationListController.php
@@ -39,33 +39,37 @@
break;
}
- $notifications = $query->executeWithOffsetPager($pager);
+ $image = id(new PHUIIconView())
+ ->setIconFont('fa-eye-slash');
+ $button = id(new PHUIButtonView())
+ ->setTag('a')
+ ->addSigil('workflow')
+ ->setColor(PHUIButtonView::SIMPLE)
+ ->setIcon($image)
+ ->setText(pht('Mark All Read'));
+ $notifications = $query->executeWithOffsetPager($pager);
+ $clear_uri = id(new PhutilURI('/notification/clear/'));
if ($notifications) {
$builder = new PhabricatorNotificationBuilder($notifications);
$builder->setUser($user);
$view = $builder->buildView()->render();
+ $clear_uri->setQueryParam(
+ 'chronoKey',
+ head($notifications)->getChronologicalKey());
} else {
$view = phutil_tag_div(
'phabricator-notification no-notifications',
$no_data);
+ $button->setDisabled(true);
}
+ $button->setHref((string) $clear_uri);
$view = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_MEDIUM)
->addClass('phabricator-notification-list')
->appendChild($view);
- $image = id(new PHUIIconView())
- ->setIconFont('fa-eye-slash');
- $button = id(new PHUIButtonView())
- ->setTag('a')
- ->setColor(PHUIButtonView::SIMPLE)
- ->setHref('/notification/clear/')
- ->addSigil('workflow')
- ->setIcon($image)
- ->setText(pht('Mark All Read'));
-
$notif_header = id(new PHUIHeaderView())
->setHeader($header)
->addActionLink($button);
diff --git a/src/applications/notification/controller/PhabricatorNotificationPanelController.php b/src/applications/notification/controller/PhabricatorNotificationPanelController.php
--- a/src/applications/notification/controller/PhabricatorNotificationPanelController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationPanelController.php
@@ -15,15 +15,29 @@
$stories = $query->execute();
+ $clear_ui_class = 'phabricator-notification-clear-all';
+ $clear_uri = id(new PhutilURI('/notification/clear/'));
if ($stories) {
$builder = new PhabricatorNotificationBuilder($stories);
$notifications_view = $builder->buildView();
$content = $notifications_view->render();
+ $clear_uri->setQueryParam(
+ 'chronoKey',
+ head($stories)->getChronologicalKey());
} else {
$content = phutil_tag_div(
'phabricator-notification no-notifications',
pht('You have no notifications.'));
+ $clear_ui_class .= ' disabled';
}
+ $clear_ui = javelin_tag(
+ 'a',
+ array(
+ 'sigil' => 'workflow',
+ 'href' => (string) $clear_uri,
+ 'class' => $clear_ui_class,
+ ),
+ pht('Mark All Read'));
$notifications_link = phutil_tag(
'a',
@@ -50,14 +64,7 @@
'<div class="phabricator-notification-view-all">%s %s %s</div>',
$header,
$content,
- javelin_tag(
- 'a',
- array(
- 'sigil' => 'workflow',
- 'href' => '/notification/clear/',
- 'class' => 'phabricator-notification-clear-all'
- ),
- pht('Mark All Read')),
+ $clear_ui,
" \xC2\xB7 ",
phutil_tag(
'a',
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 14, 8:24 PM (4 d, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722385
Default Alt Text
D10113.diff (6 KB)
Attached To
Mode
D10113: Notifications - fix race condition around "Mark All Read".
Attached
Detach File
Event Timeline
Log In to Comment