Skip to content

Commit

Permalink
Fixing onboarding bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jemoka committed Jul 10, 2021
1 parent 777ce64 commit 87a01a9
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 108 deletions.
82 changes: 81 additions & 1 deletion src/Objects/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,86 @@ function GloballySelfDestruct() {
Query.SelfDestruct();
}

export { RepeatRule, RepeatRuleType, Query, GloballySelfDestruct, Ticket, Hookifier };
async function BootstrapCondution(context:Context, username:string, payload:string) {
// create 3 new tasks and set their descriptions
(await Task.create(context, payload[0] + ` ${username}, ` + payload[1])).description = payload[2];
(await Task.create(context, payload[3])).description = payload[4];
(await Task.create(context, payload[5])).description = payload[6];

let cdyrslf = await Project.create(context, payload[7]);
let npd = await Project.create(context, payload[8]);

let od = new Date();
let ds = new Date();
od.setHours(od.getHours() - 24);
ds.setHours(ds.getHours() + 20);

let odid = await Task.create(context, payload[9], npd, [], od);
odid.description = payload[10];
await npd.associate(odid); // I believe (hope) this is the equivalent to: await associateTask(userID, odid, npd);

let dsID = await Task.create(context, payload[11], npd, [], ds);
dsID.description = payload[12];
await npd.associate(dsID);

ds.setHours(ds.getHours() + 2);
let checkoutID = await Task.create(context, payload[13]);
checkoutID.description = payload[14];

// I did not choose these variable names, I am just using the ones from the old onboarding code
let nice = await Task.create(context, payload[15], cdyrslf);
await cdyrslf.associate(nice);

let sequential = await Task.create(context, payload[16], cdyrslf);
sequential.description = payload[17];
await cdyrslf.associate(sequential);

let blocked = await Task.create(context, payload[18], cdyrslf);
blocked.description = payload[19];
await cdyrslf.associate(blocked);

let click = await Task.create(context, payload[20], cdyrslf);
click.description = payload[21];
await cdyrslf.associate(click);

let pspDir = await Task.create(context, payload[22], cdyrslf);
pspDir.description = payload[23];
await cdyrslf.associate(pspDir);

let pspsp = await Project.create(context, payload[24]);

let tags: Tag[] = await Promise.all([
Tag.create(context, payload[25]),
Tag.create(context, payload[26]),
Tag.create(context, payload[27]),
Tag.create(context, payload[28])
]);

let specific = await Task.create(context, payload[29], pspsp, [tags[2], tags[3]]);
await pspsp.associate(specific);

let sp = await Task.create(context, payload[31], pspsp, [tags[0]]);
sp.description = payload[32];
await pspsp.associate(sp);

await Perspective.create(context, payload[33], payload[34]);

let promotion = await Project.create(context, payload[35]);

let online = await Task.create(context, payload[36], promotion);
await promotion.associate(online);

let dis = await Task.create(context, payload[37], promotion);
await promotion.associate(dis);

let patreon = await Task.create(context, payload[38], promotion);
await promotion.associate(patreon);

let yiipee = await Task.create(context, payload[39], promotion);
yiipee.description = payload[40];
await promotion.associate(yiipee);
}

export { RepeatRule, RepeatRuleType, Query, GloballySelfDestruct, Ticket, Hookifier, BootstrapCondution };
export type { AdapterData, Filterable };

108 changes: 1 addition & 107 deletions src/Widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,111 +361,5 @@ class TimelineWidget extends Widget {
}
}

// A special widget to do onboarding.

class OnboardWidget extends Widget {
name = "onboard-widget"

constructor(context:Context, username: string, payload: string[]) {
super(context, {
username, payload
});
}

// async execute() {
// if (!OnboardWidget.dataPromise)
// OnboardWidget.dataPromise = this.calculate(this.tz, this.username, this.this.payload);

// let data = await OnboardWidget.dataPromise;
// return data;
// }

async calculate() {
let payload = this.payload["payload"];
let username = this.payload["username"];
console.log(this.payload);

// create 3 new tasks and set their descriptions
(await Task.create(this.query.cm, payload[0] + ` ${username}, ` + payload[1])).description = payload[2];
(await Task.create(this.query.cm, payload[3])).description = payload[4];
(await Task.create(this.query.cm, payload[5])).description = payload[6];

let cdyrslf = await Project.create(this.query.cm, payload[7]);
let npd = await Project.create(this.query.cm, payload[8]);

let od = new Date();
let ds = new Date();
od.setHours(od.getHours() - 24);
ds.setHours(ds.getHours() + 20);

let odid = await Task.create(this.query.cm, payload[9], npd, [], od);
odid.description = payload[10];
await npd.associate(odid); // I believe (hope) this is the equivalent to: await associateTask(userID, odid, npd);

let dsID = await Task.create(this.query.cm, payload[11], npd, [], ds);
dsID.description = payload[12];
await npd.associate(dsID);

ds.setHours(ds.getHours() + 2);
let checkoutID = await Task.create(this.query.cm, payload[13]);
checkoutID.description = payload[14];

// I did not choose these variable names, I am just using the ones from the old onboarding code
let nice = await Task.create(this.query.cm, payload[15], cdyrslf);
await cdyrslf.associate(nice);

let sequential = await Task.create(this.query.cm, payload[16], cdyrslf);
sequential.description = payload[17];
await cdyrslf.associate(sequential);

let blocked = await Task.create(this.query.cm, payload[18], cdyrslf);
blocked.description = payload[19];
await cdyrslf.associate(blocked);

let click = await Task.create(this.query.cm, payload[20], cdyrslf);
click.description = payload[21];
await cdyrslf.associate(click);

let pspDir = await Task.create(this.query.cm, payload[22], cdyrslf);
pspDir.description = payload[23];
await cdyrslf.associate(pspDir);

let pspsp = await Project.create(this.query.cm, payload[24]);

let tags: Tag[] = await Promise.all([
Tag.create(this.query.cm, payload[25]),
Tag.create(this.query.cm, payload[26]),
Tag.create(this.query.cm, payload[27]),
Tag.create(this.query.cm, payload[28])
]);

let specific = await Task.create(this.query.cm, payload[29], pspsp, [tags[2], tags[3]]);
await pspsp.associate(specific);

let sp = await Task.create(this.query.cm, payload[31], pspsp, [tags[0]]);
sp.description = payload[32];
await pspsp.associate(sp);

await Perspective.create(this.query.cm, payload[33], payload[34]);

let promotion = await Project.create(this.query.cm, payload[35]);

let online = await Task.create(this.query.cm, payload[36], promotion);
await promotion.associate(online);

let dis = await Task.create(this.query.cm, payload[37], promotion);
await promotion.associate(dis);

let patreon = await Task.create(this.query.cm, payload[38], promotion);
await promotion.associate(patreon);

let yiipee = await Task.create(this.query.cm, payload[39], promotion);
yiipee.description = payload[40];
await promotion.associate(yiipee);

return [{}];
}
}

export { Widget, ProjectMenuWidget, PerspectivesMenuWidget, InboxWidget, CompletedWidget, ProjectDatapackWidget, TagsPaneWidget, TagDatapackWidget, DueSoonWidget, TimelineWidget, MenuWidget, OnboardWidget };
export { Widget, ProjectMenuWidget, PerspectivesMenuWidget, InboxWidget, CompletedWidget, ProjectDatapackWidget, TagsPaneWidget, TagDatapackWidget, DueSoonWidget, TimelineWidget, MenuWidget };
//new line here

0 comments on commit 87a01a9

Please sign in to comment.