Skip to content

Commit 55add74

Browse files
Merge pull request #37 from HALFpipe/fix-import
Fix import
2 parents 40fa080 + 1c56a27 commit 55add74

File tree

6 files changed

+37
-16
lines changed

6 files changed

+37
-16
lines changed

jest.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ export default {
1515
transform: {
1616
"^.+\\.(ts|tsx)$": "ts-jest"
1717
},
18+
verbose: true,
1819
};

src/model/__tests__/database.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ describe("Database", () => {
1616
database.put(imgsArray);
1717

1818
it("gets closest image", () => {
19-
let closestImg = database.closest({"sub": "01", "type": "tsnr_rpt"});
19+
let closestImg = database.closest({sub: "01", type: "tsnr_rpt"});
2020
expect(closestImg.sub).toBe("01");
2121
expect(closestImg.type).toBe("skull_strip_report");
2222

23-
closestImg = database.closest({"sub": "03", "type": "tsnr_rpt"});
23+
closestImg = database.closest({sub: "03", type: "tsnr_rpt"});
2424
expect(closestImg.sub).toBe("01");
2525
expect(closestImg.type).toBe("skull_strip_report");
2626
});
@@ -29,7 +29,10 @@ describe("Database", () => {
2929
let [ exactImg ] = database.findAll({sub: "01", type: "skull_strip_report"});
3030
expect(exactImg.hash).toBe("1");
3131

32-
let result = database.findAll({sub: "03"});
32+
let result = database.findAll({sub: "03", type: "skull_strip_report"});
33+
expect(result.length).toBe(0);
34+
35+
result = database.findAll({sub: "03"});
3336
expect(result.length).toBe(0);
3437
});
3538

src/model/database.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,33 @@ export class Database {
4646
for (const key of basedOnEntities) {
4747
const value = obj[key];
4848

49-
if (value === null) {
49+
if (value == null) { // == catches both `null` and `undefined`
5050
continue;
5151
}
52-
if (!(value in this.indexSets[key])) {
53-
continue;
52+
if (!(value in this.indexSets[key])) { // unknown value
53+
if (exact) {
54+
return null;
55+
} else {
56+
continue;
57+
}
5458
}
5559

56-
let indexSet = this.indexSets[key][value];
57-
if (matches === null) {
60+
const indexSet = this.indexSets[key][value];
61+
62+
if (matches == null) {
5863
matches = indexSet;
5964
} else {
60-
indexSet = matches.intersection(indexSet);
61-
if (!exact && indexSet.length === 0) {
62-
break;
65+
const intersectionSet = matches.intersection(indexSet);
66+
67+
if (intersectionSet.length === 0) {
68+
if (exact) {
69+
return null;
70+
} else {
71+
break; // return what we have
72+
}
6373
}
6474

65-
matches = indexSet;
75+
matches = intersectionSet;
6676
}
6777
}
6878

src/styles/explore.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,15 @@ qc-explorer {
216216
font-weight: 600;
217217
font-size: 12.5px;
218218
}
219+
219220
img {
220-
object-fit: contain;
221221
width: 100%;
222222
height: 100%;
223+
223224
background-color: white;
225+
226+
object-fit: contain;
227+
image-rendering: crisp-edges;
224228
}
225229
}
226230
}

src/styles/zoom.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ qc-zoom {
1818
img {
1919
width: 100%;
2020
height: 100%;
21+
2122
object-fit: cover;
23+
image-rendering: crisp-edges;
2224
}
2325
}
2426

src/view/sidebar.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class Sidebar extends HTMLElement {
3636
const importButton = h(
3737
"a",
3838
[new Attribute("class", "dropdown-item")],
39-
[t("Import...")]
39+
[t("Import")]
4040
);
4141
const fileInput = h(
4242
"input",
@@ -134,11 +134,12 @@ export class Sidebar extends HTMLElement {
134134
const { rating } = obj;
135135
delete obj["rating"];
136136

137-
if (rating == "none") {
137+
if (rating === "none") {
138138
continue;
139139
}
140140

141-
for (const img of database.findAll(obj)) {
141+
const imgs = database.findAll(obj);
142+
for (const img of imgs) {
142143
viewModel.ratingsViewModel.set(img.hash, rating);
143144
}
144145
}

0 commit comments

Comments
 (0)