Skip to content

Commit 3a67c56

Browse files
committed
Unify variable case
1 parent 15abcc2 commit 3a67c56

4 files changed

Lines changed: 60 additions & 61 deletions

File tree

src/web/app.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ async function onNewMessageComposeCreated(event) {
8383
const newSubject = await ReplayMailDataCreator.createSubject({ buttonConfig, originalSubject });
8484
await OfficeDataAccessHelper.setSubjectAsync(newSubject);
8585
const recipients = ReplayMailDataCreator.getNewRecipients(buttonConfig);
86-
console.log(recipients);
8786
if (recipients.to) {
8887
await OfficeDataAccessHelper.setToAsync(recipients.to);
8988
}
@@ -93,11 +92,11 @@ async function onNewMessageComposeCreated(event) {
9392
if (recipients.bcc) {
9493
await OfficeDataAccessHelper.setBccAsync(recipients.bcc);
9594
}
96-
if (!buttonConfig.QuoteType) {
95+
if (!buttonConfig.quoteType) {
9796
await OfficeDataAccessHelper.setBodyAsync("");
9897
}
99-
if (buttonConfig.Body) {
100-
await OfficeDataAccessHelper.prependBodyAsync(`${buttonConfig.Body} \n`);
98+
if (buttonConfig.body) {
99+
await OfficeDataAccessHelper.prependBodyAsync(`${buttonConfig.body} \n`);
101100
}
102101
event.completed();
103102
}

src/web/config-loader.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ export class ConfigLoader {
3636

3737
static async loadConfigForCurrentLanguage(culture) {
3838
const typicalReplyConfig = await ConfigLoader.loadFileConfig();
39-
let config = typicalReplyConfig?.ConfigList?.find((_) => (_.Culture ?? null) === culture);
39+
let config = typicalReplyConfig?.configList?.find((_) => (_.culture ?? null) === culture);
4040
if (!config) {
4141
const lang = culture.split("-")[0];
42-
config = typicalReplyConfig?.ConfigList?.find((_) => (_.Culture ?? null) === lang);
42+
config = typicalReplyConfig?.configList?.find((_) => (_.culture ?? null) === lang);
4343
}
4444
if (!config) {
45-
config = typicalReplyConfig?.ConfigList?.[0];
45+
config = typicalReplyConfig?.configList?.[0];
4646
}
4747
return config;
4848
}
4949

5050
static async loadButtonConfig(culture, id) {
5151
const configForLang = await ConfigLoader.loadConfigForCurrentLanguage(culture);
52-
if (configForLang && configForLang.ButtonConfigList) {
53-
return configForLang.ButtonConfigList.find((conf) => conf.Id === id);
52+
if (configForLang && configForLang.buttonConfigList) {
53+
return configForLang.buttonConfigList.find((conf) => conf.id === id);
5454
}
5555
return null;
5656
}

src/web/config.mjs

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,17 @@ export class ButtonConfigEnums {
4242
}
4343

4444
export class ButtonConfig {
45-
Id;
46-
Label;
47-
SubjectPrefix;
48-
Subject;
49-
Body;
50-
Recipients;
51-
RecipientsType;
52-
QuoteType;
53-
AllowedDomains;
54-
LoweredAllowedDomains;
55-
AllowedDomainsType;
56-
ForwardType;
45+
id;
46+
label;
47+
subjectPrefix;
48+
subject;
49+
body;
50+
recipients;
51+
recipientsType;
52+
quoteType;
53+
allowedDomains;
54+
allowedDomainsType;
55+
forwardType;
5756

5857
constructor({
5958
Id,
@@ -66,59 +65,59 @@ export class ButtonConfig {
6665
AllowedDomains,
6766
ForwardType,
6867
}) {
69-
this.Id = Id ?? "";
70-
this.Label = Label ?? "";
71-
this.SubjectPrefix = SubjectPrefix ?? "";
72-
this.Subject = Subject ?? "";
73-
this.Body = Body ?? "";
74-
this.Recipients = Recipients ?? [];
75-
this.QuoteType = QuoteType ?? false;
76-
this.AllowedDomains = AllowedDomains ?? [];
77-
this.ForwardType =
68+
this.id = Id ?? "";
69+
this.label = Label ?? "";
70+
this.subjectPrefix = SubjectPrefix ?? "";
71+
this.subject = Subject ?? "";
72+
this.body = Body ?? "";
73+
this.recipients = Recipients ?? [];
74+
this.quoteType = QuoteType ?? false;
75+
this.allowedDomains = AllowedDomains ?? [];
76+
this.forwardType =
7877
getEnumValueByKey(ButtonConfigEnums.ForwardType, ForwardType) ??
7978
ButtonConfigEnums.ForwardType.Unknown;
8079

8180
if (!Recipients || Recipients.length == 0) {
82-
this.RecipientsType = ButtonConfigEnums.RecipientsType.Blank;
81+
this.recipientsType = ButtonConfigEnums.RecipientsType.Blank;
8382
} else {
84-
this.RecipientsType = getEnumValueByKey(ButtonConfigEnums.RecipientsType, Recipients[0].toLowerCase())
83+
this.recipientsType = getEnumValueByKey(ButtonConfigEnums.RecipientsType, Recipients[0].toLowerCase())
8584
?? ButtonConfigEnums.RecipientsType.SpecifiedByUser;
8685
}
8786

8887
if (!AllowedDomains || AllowedDomains.length == 0 || AllowedDomains[0] === "*") {
89-
this.AllowedDomainsType = ButtonConfigEnums.AllowedDomainsType.Blank;
88+
this.allowedDomainsType = ButtonConfigEnums.AllowedDomainsType.Blank;
9089
} else {
91-
this.AllowedDomainsType = ButtonConfigEnums.AllowedDomainsType.SpecifiedByUser;
90+
this.allowedDomainsType = ButtonConfigEnums.AllowedDomainsType.SpecifiedByUser;
9291
}
9392
}
9493
}
9594

9695
export class Config {
97-
Culture;
98-
GroupLabel;
99-
ButtonConfigList;
96+
culture;
97+
groupLabel;
98+
buttonConfigList;
10099

101100
constructor({ Culture, GroupLabel, ButtonConfigList }) {
102-
this.Culture = Culture ?? "en-US";
103-
this.GroupLabel = GroupLabel ?? "Typical Reply";
104-
this.ButtonConfigList = [];
101+
this.culture = Culture ?? "en-US";
102+
this.groupLabel = GroupLabel ?? "Typical Reply";
103+
this.buttonConfigList = [];
105104
if (ButtonConfigList) {
106105
for (const buttonConfig of ButtonConfigList) {
107-
this.ButtonConfigList.push(new ButtonConfig(buttonConfig));
106+
this.buttonConfigList.push(new ButtonConfig(buttonConfig));
108107
}
109108
}
110109
}
111110
}
112111

113112
export class TypicalReplyConfig {
114-
Priority;
115-
ConfigList;
113+
priority;
114+
configList;
116115
constructor({ Priority, ConfigList }) {
117-
this.Priority = Priority ?? 0;
118-
this.ConfigList = [];
116+
this.priority = Priority ?? 0;
117+
this.configList = [];
119118
if (ConfigList) {
120119
for (const config of ConfigList) {
121-
this.ConfigList.push(new Config(config));
120+
this.configList.push(new Config(config));
122121
}
123122
}
124123
}

src/web/mail-data-creator.mjs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as RecipientParser from "./recipient-parser.mjs";
1010

1111
export class ReplayMailDataCreator {
1212
static getReplyFormFunction(buttonConfig) {
13-
switch (buttonConfig.RecipientsType) {
13+
switch (buttonConfig.recipientsType) {
1414
case ButtonConfigEnums.RecipientsType.All:
1515
return Office.context.mailbox.item.displayReplyAllFormAsync;
1616
case ButtonConfigEnums.RecipientsType.Sender:
@@ -22,9 +22,10 @@ export class ReplayMailDataCreator {
2222
}
2323
}
2424

25+
2526
static isAllRecipientsAllowed({ buttonConfig, originalMailData }) {
2627
let recipients;
27-
switch (buttonConfig.RecipientsType) {
28+
switch (buttonConfig.recipientsType) {
2829
case ButtonConfigEnums.RecipientsType.All:
2930
recipients = [
3031
...(originalMailData.toRecipients ?? []),
@@ -39,13 +40,13 @@ export class ReplayMailDataCreator {
3940
}
4041
break;
4142
case ButtonConfigEnums.RecipientsType.SpecifiedByUser:
42-
recipients = buttonConfig.Recipients ?? [];
43+
recipients = buttonConfig.recipients ?? [];
4344
break;
4445
default:
4546
break;
4647
}
47-
if (buttonConfig.AllowedDomainsType == ButtonConfigEnums.AllowedDomainsType.SpecifiedByUser) {
48-
const loweredAllowedDomains = buttonConfig.AllowedDomains.map((domain) =>
48+
if (buttonConfig.allowedDomainsType == ButtonConfigEnums.AllowedDomainsType.SpecifiedByUser) {
49+
const loweredAllowedDomains = buttonConfig.allowedDomains.map((domain) =>
4950
domain.toLowerCase()
5051
);
5152
for (const recipient of recipients) {
@@ -67,7 +68,7 @@ export class ReplayMailDataCreator {
6768
if (!originalMailData.id) {
6869
return [];
6970
}
70-
switch (buttonConfig.ForwardType) {
71+
switch (buttonConfig.forwardType) {
7172
case ButtonConfigEnums.ForwardType.Attachment:
7273
return [
7374
{
@@ -90,11 +91,11 @@ export class ReplayMailDataCreator {
9091
}
9192

9293
static getNewRecipients(buttonConfig) {
93-
console.log(buttonConfig.RecipientsType);
94-
switch (buttonConfig.RecipientsType) {
94+
console.log(buttonConfig.recipientsType);
95+
switch (buttonConfig.recipientsType) {
9596
case ButtonConfigEnums.RecipientsType.SpecifiedByUser:
9697
return {
97-
to: buttonConfig.Recipients,
98+
to: buttonConfig.recipients,
9899
cc: [],
99100
bcc: [],
100101
};
@@ -103,15 +104,15 @@ export class ReplayMailDataCreator {
103104
}
104105
}
105106

106-
static createSubject({ buttonConfig, originalSuject }) {
107+
static createSubject({ buttonConfig, originalSubject }) {
107108
let newSubject = "";
108-
if (buttonConfig.Subject) {
109-
newSubject = buttonConfig.Subject;
109+
if (buttonConfig.subject) {
110+
newSubject = buttonConfig.subject;
110111
} else {
111-
newSubject = originalSuject;
112+
newSubject = originalSubject;
112113
}
113-
if (buttonConfig.SubjectPrefix) {
114-
newSubject = `${buttonConfig.SubjectPrefix} ${newSubject ?? ""}`;
114+
if (buttonConfig.subjectPrefix) {
115+
newSubject = `${buttonConfig.subjectPrefix} ${newSubject ?? ""}`;
115116
}
116117
return newSubject;
117118
}

0 commit comments

Comments
 (0)