Bug 1659558 - Part 7: Convert `cal.createRelation()` to `new CalRelation()`. r=darktrojan
Differential Revision: https://phabricator.services.mozilla.com/D89275 --HG-- extra : rebase_source : 5bbbb6cd22490a98885d549eddd4d9c6010363fc
This commit is contained in:
Родитель
4ada409e33
Коммит
a26956574a
|
@ -29,7 +29,6 @@ var cal = {
|
|||
// as well as getting services and other (cached) objects.
|
||||
createDateTime: _instance("@mozilla.org/calendar/datetime;1", Ci.calIDateTime, "icalString"),
|
||||
createDuration: _instance("@mozilla.org/calendar/duration;1", Ci.calIDuration, "icalString"),
|
||||
createRelation: _instance("@mozilla.org/calendar/relation;1", Ci.calIRelation, "icalString"),
|
||||
createRecurrenceDate: _instance(
|
||||
"@mozilla.org/calendar/recurrence-date;1",
|
||||
Ci.calIRecurrenceDate,
|
||||
|
|
|
@ -11,6 +11,7 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
});
|
||||
|
||||
ChromeUtils.defineModuleGetter(this, "cal", "resource:///modules/calendar/calUtils.jsm");
|
||||
|
@ -1153,7 +1154,7 @@ var calitip = {
|
|||
// reset to a new UUID if applicable
|
||||
item.id = aUid || cal.getUUID();
|
||||
// add a relation to the original item
|
||||
let relation = cal.createRelation();
|
||||
let relation = new CalRelation();
|
||||
relation.relId = aItem.id;
|
||||
relation.relType = "SIBLING";
|
||||
item.addRelation(relation);
|
||||
|
|
|
@ -7,14 +7,18 @@ var EXPORTED_SYMBOLS = ["CalRelation"];
|
|||
var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm");
|
||||
|
||||
/**
|
||||
* calRelation prototype definition
|
||||
* Constructor for `calIRelation` objects.
|
||||
*
|
||||
* @implements calIRelation
|
||||
* @constructor
|
||||
* @class
|
||||
* @implements {calIRelation}
|
||||
* @param {string} [icalString] - Optional iCal string for initializing existing relations.
|
||||
*/
|
||||
function CalRelation() {
|
||||
function CalRelation(icalString) {
|
||||
this.wrappedJSObject = this;
|
||||
this.mProperties = new Map();
|
||||
if (icalString) {
|
||||
this.icalString = icalString;
|
||||
}
|
||||
}
|
||||
CalRelation.prototype = {
|
||||
QueryInterface: ChromeUtils.generateQI(["calIRelation"]),
|
||||
|
|
|
@ -18,6 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
CalTodo: "resource:///modules/CalTodo.jsm",
|
||||
});
|
||||
|
||||
|
@ -1808,7 +1809,7 @@ CalStorageCalendar.prototype = {
|
|||
await this.executeAsync(this.mSelectAllRelations, row => {
|
||||
let item = itemsMap.get(row.getResultByName("item_id"));
|
||||
if (item) {
|
||||
item.addRelation(cal.createRelation(row.getResultByName("icalString")));
|
||||
item.addRelation(new CalRelation(row.getResultByName("icalString")));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2081,7 +2082,7 @@ CalStorageCalendar.prototype = {
|
|||
this.prepareStatement(selectRelation);
|
||||
selectRelation.params.item_id = item.id;
|
||||
await this.executeAsync(selectRelation, row => {
|
||||
item.addRelation(cal.createRelation(row.getResultByName("icalString")));
|
||||
item.addRelation(new CalRelation(row.getResultByName("icalString")));
|
||||
});
|
||||
} catch (e) {
|
||||
this.logError(
|
||||
|
|
|
@ -79,6 +79,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
CalAlarm: "resource:///modules/CalAlarm.jsm",
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
});
|
||||
|
||||
// The current database version. Be sure to increment this when you create a new
|
||||
|
@ -1653,7 +1654,7 @@ upgrade.v22 = function(db, version) {
|
|||
onFunctionCall(storArgs) {
|
||||
try {
|
||||
let [aRelType, aRelId] = mapStorageArgs(storArgs);
|
||||
let relation = cal.createRelation();
|
||||
let relation = new CalRelation();
|
||||
relation.relType = aRelType;
|
||||
relation.relId = aRelId;
|
||||
return relation.icalString;
|
||||
|
|
|
@ -6,11 +6,12 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
let evt = new CalEvent();
|
||||
let rel = cal.createRelation();
|
||||
let rel = new CalRelation();
|
||||
evt.addRelation(rel);
|
||||
|
||||
equal(1, evt.icalString.match(/RELATED-TO/g).length);
|
||||
|
|
|
@ -8,6 +8,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
CalTodo: "resource:///modules/CalTodo.jsm",
|
||||
});
|
||||
|
||||
|
@ -168,7 +169,7 @@ function test_folding() {
|
|||
function test_icalProps() {
|
||||
checkIcalProp("ATTACH", new CalAttachment());
|
||||
checkIcalProp("ATTENDEE", new CalAttendee());
|
||||
checkIcalProp("RELATED-TO", cal.createRelation());
|
||||
checkIcalProp("RELATED-TO", new CalRelation());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -7,6 +7,7 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
|
|||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalAttachment: "resource:///modules/CalAttachment.jsm",
|
||||
CalAttendee: "resource:///modules/CalAttendee.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
|
@ -73,7 +74,7 @@ function test_icalstring() {
|
|||
);
|
||||
|
||||
checkComp(
|
||||
cal.createRelation.bind(cal),
|
||||
icalString => new CalRelation(icalString),
|
||||
"RELATED-TO;RELTYPE=SIBLING;FOO=BAR:VALUE",
|
||||
{ relType: "SIBLING", relId: "VALUE" },
|
||||
{ FOO: "BAR" }
|
||||
|
|
|
@ -6,11 +6,12 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm")
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
CalEvent: "resource:///modules/CalEvent.jsm",
|
||||
CalRelation: "resource:///modules/CalRelation.jsm",
|
||||
});
|
||||
|
||||
function run_test() {
|
||||
// Create Relation
|
||||
let relation1 = cal.createRelation();
|
||||
let relation1 = new CalRelation();
|
||||
|
||||
// Create Items
|
||||
let event1 = new CalEvent();
|
||||
|
@ -31,7 +32,7 @@ function run_test() {
|
|||
event1.addRelation(relation1);
|
||||
|
||||
// Add 2nd relation to event.
|
||||
let relation2 = cal.createRelation();
|
||||
let relation2 = new CalRelation();
|
||||
relation2.relId = "myid2";
|
||||
event1.addRelation(relation2);
|
||||
|
||||
|
@ -83,7 +84,7 @@ function modifyRelations(event, oldRel) {
|
|||
}
|
||||
|
||||
function test_icalprop() {
|
||||
let rel = cal.createRelation();
|
||||
let rel = new CalRelation();
|
||||
|
||||
rel.relType = "SIBLING";
|
||||
rel.setParameter("X-PROP", "VAL");
|
||||
|
|
Загрузка…
Ссылка в новой задаче