Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty watchlist fixes #575

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
</>
);
};
};
Loading