convert firstDayOfWeek: number -> string
This commit is contained in:
Vendored
+4
-24
@@ -281,20 +281,6 @@
|
|||||||
function checkIsValidObject(object) {
|
function checkIsValidObject(object) {
|
||||||
return object.dataVersion == DATA_VERSION;
|
return object.dataVersion == DATA_VERSION;
|
||||||
}
|
}
|
||||||
function checkMatchesObjectStructure(objectToCheck, reference) {
|
|
||||||
for (const key of Object.keys(reference)) {
|
|
||||||
const requiredType = typeof reference[key];
|
|
||||||
const actualType = typeof objectToCheck[key];
|
|
||||||
if (requiredType != actualType) return false;
|
|
||||||
if (requiredType != "object") continue;
|
|
||||||
const doesNestedObjectMatch = checkMatchesObjectStructure(
|
|
||||||
reference[key],
|
|
||||||
objectToCheck[key]
|
|
||||||
);
|
|
||||||
if (doesNestedObjectMatch == false) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// src/Model/Utility/utility.ts
|
// src/Model/Utility/utility.ts
|
||||||
function createTimestamp() {
|
function createTimestamp() {
|
||||||
@@ -2160,7 +2146,7 @@
|
|||||||
setFirstDayOfWeek(newValue) {
|
setFirstDayOfWeek(newValue) {
|
||||||
this.firstDayOfWeek = newValue;
|
this.firstDayOfWeek = newValue;
|
||||||
const path = storageKeys.firstDayOfWeek;
|
const path = storageKeys.firstDayOfWeek;
|
||||||
this.storageModel.writeStringifiable(path, newValue);
|
this.storageModel.write(path, newValue);
|
||||||
}
|
}
|
||||||
// load
|
// load
|
||||||
loadUsernam() {
|
loadUsernam() {
|
||||||
@@ -2170,8 +2156,8 @@
|
|||||||
}
|
}
|
||||||
loadFirstDayofWeek() {
|
loadFirstDayofWeek() {
|
||||||
const path = storageKeys.firstDayOfWeek;
|
const path = storageKeys.firstDayOfWeek;
|
||||||
const content = this.storageModel.readStringifiable(path);
|
const content = this.storageModel.read(path);
|
||||||
this.firstDayOfWeek = content ?? 0;
|
this.firstDayOfWeek = content ?? "0";
|
||||||
}
|
}
|
||||||
// init
|
// init
|
||||||
constructor(storageModel2) {
|
constructor(storageModel2) {
|
||||||
@@ -2187,7 +2173,7 @@
|
|||||||
// state
|
// state
|
||||||
username = new State("");
|
username = new State("");
|
||||||
usernameInput = new State("");
|
usernameInput = new State("");
|
||||||
firstDayOfWeekInput = new State(0);
|
firstDayOfWeekInput = new State("0");
|
||||||
// guards
|
// guards
|
||||||
cannotSetName = createProxyState(
|
cannotSetName = createProxyState(
|
||||||
[this.usernameInput],
|
[this.usernameInput],
|
||||||
@@ -2388,10 +2374,4 @@
|
|||||||
ConnectionModal(connectionViewModel),
|
ConnectionModal(connectionViewModel),
|
||||||
StorageModal(storageViewModel)
|
StorageModal(storageViewModel)
|
||||||
);
|
);
|
||||||
console.log(
|
|
||||||
checkMatchesObjectStructure(
|
|
||||||
{ a: 4263, b: "bla", d: true, c: [1, 2] },
|
|
||||||
{ a: 123, b: "hello", d: false, c: [1, 3] }
|
|
||||||
)
|
|
||||||
);
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default class SettingsModel {
|
|||||||
storageModel: StorageModel;
|
storageModel: StorageModel;
|
||||||
|
|
||||||
username: string;
|
username: string;
|
||||||
firstDayOfWeek: number;
|
firstDayOfWeek: string;
|
||||||
|
|
||||||
// set
|
// set
|
||||||
setName(newValue: string): void {
|
setName(newValue: string): void {
|
||||||
@@ -15,10 +15,10 @@ export default class SettingsModel {
|
|||||||
this.storageModel.write(path, newValue);
|
this.storageModel.write(path, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
setFirstDayOfWeek(newValue: number): void {
|
setFirstDayOfWeek(newValue: string): void {
|
||||||
this.firstDayOfWeek = newValue;
|
this.firstDayOfWeek = newValue;
|
||||||
const path = storageKeys.firstDayOfWeek;
|
const path = storageKeys.firstDayOfWeek;
|
||||||
this.storageModel.writeStringifiable(path, newValue);
|
this.storageModel.write(path, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load
|
// load
|
||||||
@@ -30,8 +30,8 @@ export default class SettingsModel {
|
|||||||
|
|
||||||
loadFirstDayofWeek(): void {
|
loadFirstDayofWeek(): void {
|
||||||
const path = storageKeys.firstDayOfWeek;
|
const path = storageKeys.firstDayOfWeek;
|
||||||
const content = this.storageModel.readStringifiable(path);
|
const content = this.storageModel.read(path);
|
||||||
this.firstDayOfWeek = content ?? 0;
|
this.firstDayOfWeek = content ?? "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
// init
|
// init
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export default class SettingsViewModel {
|
|||||||
// state
|
// state
|
||||||
username: React.State<string> = new React.State("");
|
username: React.State<string> = new React.State("");
|
||||||
usernameInput: React.State<string> = new React.State("");
|
usernameInput: React.State<string> = new React.State("");
|
||||||
firstDayOfWeekInput: React.State<number> = new React.State(0);
|
firstDayOfWeekInput: React.State<string> = new React.State("0");
|
||||||
|
|
||||||
// guards
|
// guards
|
||||||
cannotSetName: React.State<boolean> = React.createProxyState(
|
cannotSetName: React.State<boolean> = React.createProxyState(
|
||||||
|
|||||||
Reference in New Issue
Block a user