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

fix(android): add missing “Calendar.Event.remove” method #14076

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

hansemannn
Copy link
Collaborator

Fixes an issue where calendar events could not be deleted programmatically on Android, yet.

@hansemannn hansemannn requested a review from m1ga July 6, 2024 17:36
@m1ga
Copy link
Contributor

m1ga commented Jul 7, 2024

I've created some test code:

var win = Ti.UI.createWindow({
	layout: "vertical"
});
var btn1 = Ti.UI.createButton({
	title: "add"
});
var btn2 = Ti.UI.createButton({
	title: "delete"
});
win.add([btn1, btn2]);
win.open();
var event = null;
btn1.addEventListener("click", function() {
	var calendar = Ti.Calendar.defaultCalendar;

	// Create the event
	var eventBegins = new Date(2024, 8, 1, 12, 0, 0);
	var eventEnds = new Date(2024, 8, 1, 14, 0, 0);
	var details = {
		title: 'Do some stuff',
		description: "I'm going to do some stuff at this time.",
		begin: eventBegins,
		end: eventEnds
	};

	if (calendar == null) {
		console.log("calendar is empty")
		return;
	}
	event = calendar.createEvent(details);

	console.log("done", event.id);
})

btn2.addEventListener("click", function() {
	if (event) {
		console.log(event.remove());
	}
});

It works fine. Looks like the calendar is caching the events for some seconds so in case you test it in split-screen mode it doesn't update the calendar right away when you add/remove an event.

Small note:
can you add something like Android: parameter is the event id you want to remove to the docs, as it is not clear what the parameter should be because you call it with event.remove() already and the span is something different on iOS. BTW: it doesn't link to constants

@hansemannn
Copy link
Collaborator Author

Ohh, good catch. We don't even need to pass the ID, I'll remove that!

Copy link
Contributor

@m1ga m1ga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Working fine now without a parameter 👍

@hansemannn hansemannn merged commit d1bbe8a into tidev:master Jul 10, 2024
6 checks passed
@hansemannn hansemannn deleted the fix/android-event-remove branch July 10, 2024 08:33
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

Successfully merging this pull request may close these issues.

2 participants