mirror of
https://github.com/YouHaveTrouble/DiscipleOfLand.git
synced 2026-05-11 22:16:55 +00:00
fix default filters not parsing correctly
This commit is contained in:
@@ -135,8 +135,7 @@ export default defineComponent({
|
|||||||
watch: {
|
watch: {
|
||||||
filters: {
|
filters: {
|
||||||
handler(newFilters) {
|
handler(newFilters) {
|
||||||
const filters = new Filters(newFilters);
|
window.localStorage.setItem("filters", newFilters.serialize());
|
||||||
window.localStorage.setItem("filters", filters.serialize());
|
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
|
|||||||
+25
-10
@@ -18,7 +18,13 @@ export default class Filters {
|
|||||||
) {
|
) {
|
||||||
this.minLevel = data?.minLevel || 91;
|
this.minLevel = data?.minLevel || 91;
|
||||||
this.maxLevel = data?.maxLevel || 100;
|
this.maxLevel = data?.maxLevel || 100;
|
||||||
const jobData = data?.jobs || [Job.BOTANIST, Job.MINER];
|
let jobData = [
|
||||||
|
Job.BOTANIST.toLowerCase(),
|
||||||
|
Job.MINER.toLowerCase()
|
||||||
|
];
|
||||||
|
if (data?.jobs && Array.isArray(data?.jobs) && data?.jobs?.length > 0) {
|
||||||
|
jobData = data.jobs;
|
||||||
|
}
|
||||||
|
|
||||||
for (const job of jobData) {
|
for (const job of jobData) {
|
||||||
const parsedJob = jobFromString(job);
|
const parsedJob = jobFromString(job);
|
||||||
@@ -26,24 +32,33 @@ export default class Filters {
|
|||||||
this.jobs.add(parsedJob);
|
this.jobs.add(parsedJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodeTypeData = data?.nodeTypes || [
|
let nodeTypeData = [
|
||||||
NodeType.UNSPOILED,
|
NodeType.UNSPOILED.toLowerCase(),
|
||||||
];
|
];
|
||||||
|
if (data?.nodeTypes && Array.isArray(data?.nodeTypes) && data?.nodeTypes?.length > 0) {
|
||||||
for (const nodeType of nodeTypeData) {
|
nodeTypeData = data.nodeTypes;
|
||||||
const parsedNodeType = nodeTypeFromString(nodeType);
|
|
||||||
if (!parsedNodeType) continue;
|
|
||||||
this.nodeTypes.add(parsedNodeType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(nodeTypeData)) {
|
||||||
|
for (const nodeType of nodeTypeData) {
|
||||||
|
const parsedNodeType = nodeTypeFromString(nodeType);
|
||||||
|
if (!parsedNodeType) continue;
|
||||||
|
this.nodeTypes.add(parsedNodeType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serialize(): string {
|
serialize(): string {
|
||||||
|
const serializedJobs = Array.from(this.jobs);
|
||||||
|
const serializedNodeTypes = Array.from(this.nodeTypes);
|
||||||
|
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
minLevel: this.minLevel,
|
minLevel: this.minLevel,
|
||||||
maxLevel: this.maxLevel,
|
maxLevel: this.maxLevel,
|
||||||
jobs: Array.from(this.jobs).map(job => job),
|
jobs: serializedJobs,
|
||||||
nodeTypes: Array.from(this.nodeTypes).map(nodeType => nodeType),
|
nodeTypes: serializedNodeTypes,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user