Skip to content

Commit

Permalink
Merge pull request #575 from privacy-tech-lab/empty-watchlist-fixes
Browse files Browse the repository at this point in the history
Empty watchlist fixes
  • Loading branch information
dadak-dom authored Jun 18, 2024
2 parents 04a931d + 6767501 commit 4ca0fbe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/background/analysis/buildUserData/importSearchData.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export async function importData() {
} else {
for (let [t, val] of Object.entries(keywordObject)) {
if (t == "keyword") {
//If the useres watchlist is not current, then update it
//If the user's watchlist is not current, then update it
if (val != retJson.ip) {
await saveKeyword(retJson.ip, typeEnum.ipAddress, "ip", true);
await saveKeyword(locKey, permissionEnum.location, "loc", true);
Expand Down Expand Up @@ -173,7 +173,9 @@ export async function importData() {
keyword: zipRegex,
keywordHash: locHash,
});
userZipArr.push(zipObj);
if (zip[0] != "") {
userZipArr.push(zipObj);
}
});

locElems[typeEnum.zipCode] = userZipArr;
Expand All @@ -184,7 +186,7 @@ export async function importData() {
locElems[typeEnum.region] = [];
const userRegion = user_store_dict[typeEnum.region];
userRegion.forEach((region) => {
if (!locElems[typeEnum.region].includes(region[0])) {
if (!locElems[typeEnum.region].includes(region[0]) && region[0] != "") {
var regex = getRegion(region[0]);
locElems[typeEnum.region].push(
new KeywordObject({ keyword: regex, keywordHash: region[1] })
Expand Down
31 changes: 26 additions & 5 deletions src/options/views/watchlist-view/components/edit-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ import { requestNotificationPermission } from "../../../../../libs/indexed-db/no
* @param {string} obj.id
* @param {function():void} obj.updateList
*/
export const EditModal = ({ passKeywordType, passKeyword, edit, id, updateList }) => {
export const EditModal = ({
passKeywordType,
passKeyword,
edit,
id,
updateList,
}) => {
const dropdownRef = useRef();
const [showDropdown, setDropdown] = useState(false);
const [showDropdown, setDropdown] = useState(false);
const [keywordType, setKeywordType] = useState(
edit ? passKeywordType : "Select Type"
);
Expand Down Expand Up @@ -201,13 +207,28 @@ export const EditModal = ({ passKeywordType, passKeyword, edit, id, updateList }
<SAction
onClick={async () => {
let key;
let displayValue;
// Some cases to fix the formatting if the user decides to only input certain parts of a street address to the watchlist
if (address == "") {
if (region == "") {
if (zip == "") {
displayValue = `${city}`;
} else {
displayValue = `${city}, ${zip}`;
}
} else {
displayValue = `${region}, ${city} ${zip}`;
}
} else {
displayValue = `${address}, ${city}, ${region} ${zip}`;
}
if (keywordType == permissionEnum.location) {
key = {
[typeEnum.streetAddress]: (address == "" ? null : address),
[typeEnum.streetAddress]: address == "" ? null : address,
[typeEnum.zipCode]: zip,
[typeEnum.region]: region,
[typeEnum.city]: city,
display: (address != "") ? `${address}, ${city}, ${region} ${zip}` : ` ${city}, ${region} ${zip}`,
display: displayValue,
};
} else {
key = keyword;
Expand Down Expand Up @@ -263,4 +284,4 @@ export const EditModal = ({ passKeywordType, passKeyword, edit, id, updateList }
</SContent>
</>
);
};
};

0 comments on commit 4ca0fbe

Please sign in to comment.