calender: Use datetime property to set timestamp for notifications

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3103>
This commit is contained in:
Julian Sparber 2024-01-26 14:55:32 +01:00 committed by Marge Bot
parent f8fce24d5c
commit 15056527aa

View File

@ -14,7 +14,7 @@ import * as Mpris from './mpris.js';
import * as PopupMenu from './popupMenu.js';
import {ensureActorVisibleInScrollView} from '../misc/animationUtils.js';
import {formatDateWithCFormatString, formatTimeSpan} from '../misc/dateUtils.js';
import {formatDateWithCFormatString} from '../misc/dateUtils.js';
import {loadInterfaceXML} from '../misc/fileUtils.js';
const SHOW_WEEKDATE_KEY = 'show-weekdate';
@ -773,6 +773,7 @@ class NotificationMessage extends MessageList.Message {
this.setUseBodyMarkup(notification.bannerBodyMarkup);
this.notification = notification;
this.datetime = notification.datetime;
this.setIcon(this._getIcon());
@ -802,6 +803,7 @@ class NotificationMessage extends MessageList.Message {
}
_onUpdated(n, _clear) {
this.datetime = n.datetime;
this.setIcon(this._getIcon());
this.setTitle(n.title);
this.setBody(n.bannerBodyText);
@ -817,24 +819,6 @@ class NotificationMessage extends MessageList.Message {
}
});
const TimeLabel = GObject.registerClass(
class NotificationTimeLabel extends St.Label {
_init(datetime) {
super._init({
style_class: 'event-time',
x_align: Clutter.ActorAlign.START,
y_align: Clutter.ActorAlign.END,
x_expand: true,
});
this._datetime = datetime;
}
vfunc_map() {
this.text = formatTimeSpan(this._datetime);
super.vfunc_map();
}
});
const NotificationSection = GObject.registerClass(
class NotificationSection extends MessageList.MessageListSection {
_init() {
@ -860,7 +844,6 @@ class NotificationSection extends MessageList.MessageListSection {
_onNotificationAdded(source, notification) {
let message = new NotificationMessage(notification);
message.setSecondaryActor(new TimeLabel(notification.datetime));
let isUrgent = notification.urgency === MessageTray.Urgency.CRITICAL;
@ -870,7 +853,6 @@ class NotificationSection extends MessageList.MessageListSection {
this._nUrgent--;
},
'updated', () => {
message.setSecondaryActor(new TimeLabel(notification.datetime));
this.moveMessage(message, isUrgent ? 0 : this._nUrgent, this.mapped);
}, this);