Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification Timestamp options not work propery #121

Open
cupsos opened this issue Dec 22, 2022 · 0 comments
Open

Notification Timestamp options not work propery #121

cupsos opened this issue Dec 22, 2022 · 0 comments

Comments

@cupsos
Copy link

cupsos commented Dec 22, 2022

Bug

Windows notification timestamp is always January 1. (probably 1970-01-01)

notification-tiemstamp

Environment

Windows 11 22H2 Microsoft Edge 108.0.1462.54

Bug reason

HTML5 Notification.timestamp is number format.

From Spec

A notification has an associated timestamp which is an EpochTimeStamp representing the time.

From MDN

A number representing a timestamp, given as Unix time in milliseconds.

But this library pass timestamp as string format. ISO 8601

public DateTime Timestamp { get; set; } = DateTime.UtcNow;

public async ValueTask<Guid> ShowsAsync(HtmlNotificationOptions notificationOptions)
{
var module = await _moduleTask.Value;
var id = Guid.NewGuid();
var info = new HtmlNotificationEventInfo(id,
notificationOptions.OnOpenCallback,
notificationOptions.OnClickCallback,
notificationOptions.OnCloseCallback,
notificationOptions.OnErrorCallback);
var dotnetRef = DotNetObjectReference.Create<HtmlNotificationEventInfo>(info);
_dotNetObjectReferences.Add(dotnetRef);
await module.InvokeVoidAsync("showSimple", id.ToString(), notificationOptions, dotnetRef);
return id;
}

//Instance methods
export function showSimple(id, options, dotnetRef) {
if (!id || !options) {
return;
}
let notification = new Notification(options.title, options);
if (dotnetRef) {
notification.onshow = (event) => { dotnetRef.invokeMethodAsync("OnOpen"); };
notification.onclose = (event) => { dotnetRef.invokeMethodAsync("OnClose"); };
notification.onerror = (event) => { dotnetRef.invokeMethodAsync("OnError"); };
notification.onclick = (event) => { dotnetRef.invokeMethodAsync("OnClick"); };
}
return notification;
}

cupsos added a commit to cupsos/blazor-components that referenced this issue Dec 22, 2022
cupsos added a commit to cupsos/blazor-components that referenced this issue Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant