Skip to content

Commit

Permalink
Version 6.1.1 (#142)
Browse files Browse the repository at this point in the history
* feat: allow configuration of if/when to show release notes after update

* fix: only show create filter modal on requesting tab; fixes #140

* feat: apply user filters to status updates

* fix: hide metadata indicators on status updates

* fix: remove (currently) unused history permission

* chore: don't export `useStyles()` for MetadataFiltersForm component

* chore: update markdownlint rules configuration

* chore: remove bootstrap dependency from renovate package rules

* chore: remove version definition from source manifest.json file

* chore: remove empty CONTRIBUTING.md file

* update version to v6.1.1; add v6.1.1 release notes page

* replace `Object.fromEntries` with reducer (re #141)

* update Chrome and Firefox minimum versions

* chore: attempt to use browserslist to avoid compatibility issues

* chore: add browserslist to project dictionary files

* chore: remove unused (and invalid) tasks.json file

* adjust verbiage of "show update page" menu options

* adjust error verbiage/display in create filters modal

* feat: open release notes page in background on update

* reject fetch metadata promises with error on failure

* docs: add bug fix for Waterfox to v6.1.1 release page

* chore: update dependencies
  • Loading branch information
rthaut authored May 23, 2020
1 parent fa67513 commit 6b85451
Show file tree
Hide file tree
Showing 27 changed files with 464 additions and 506 deletions.
4 changes: 3 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"MD001": false,
"MD013": false,
"MD024": false
"MD026": false,
"MD033": false
}
1 change: 1 addition & 0 deletions .vscode/cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"language": "en",
// words - list of words to be always considered correct
"words": [
"browserslist",
"deviantart",
"greasemonkey",
"notistack",
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"cSpell.enabled": true,
"cSpell.language": "en",
"cSpell.words": [
"browserslist",
"deviantart",
"greasemonkey",
"notistack",
"polyfill",
"subdomain",
"subdomains",
Expand Down
15 changes: 0 additions & 15 deletions .vscode/tasks.json

This file was deleted.

1 change: 0 additions & 1 deletion CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DeviantArt Filter 6.1.0
# DeviantArt Filter

> This browser extension allows you to filter/block/hide deviations by user, keyword, and/or category on DeviantArt
Expand Down
27 changes: 24 additions & 3 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@
"Options_EnabledPages_PageLabel_Notifications": {
"message": "Notifications Page"
},
"Options_ShowUpdatedPage_Header": {
"message": "Show Release Notes for Updates"
},
"Options_ShowUpdatedPage_HelpText": {
"message": "Use this to control if/when release notes are shown after the extension is updated."
},
"Options_ShowUpdatedPage_OptionLabel_Major": {
"message": "Show for major updates only"
},
"Options_ShowUpdatedPage_OptionLabel_Minor": {
"message": "Show for most updates"
},
"Options_ShowUpdatedPage_OptionLabel_Patch": {
"message": "Show for every update"
},
"Options_ShowUpdatedPage_OptionLabel_None": {
"message": "Never show for any updates"
},
"OptionsResetButtonLabel": {
"message": "Reset to Defaults"
},
Expand Down Expand Up @@ -317,12 +335,15 @@
"message": "Close"
},
"CreateFiltersFromDeviation_Error_FetchingMetadata": {
"message": "An error occurred while retrieving deviation metadata. Please try again."
"message": "An error occurred while retrieving deviation metadata."
},
"CreateFiltersFromDeviation_Error_CreatingFilters": {
"message": "An error occurred while creating filters. Please try again."
"message": "An error occurred while creating filters."
},
"CreateFiltersFromDeviation_Error_Instructions": {
"message": "If the problem persists, please report it with the following information:"
"message": "Please refresh the page and try again. If the problem persists, please report it."
},
"CreateFiltersFromDeviation_Error_Instructions_HasError": {
"message": "Please refresh the page and try again. If the problem persists, please report it with the following information:"
}
}
6 changes: 2 additions & 4 deletions app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "__MSG_ExtensionName__",
"short_name": "__MSG_ExtensionShortName__",
"description": "__MSG_ExtensionDescription__",
"version": "6.1.0",
"homepage_url": "https://rthaut.github.io/deviantART-Filter",
"manifest_version": 2,
"default_locale": "en",
Expand Down Expand Up @@ -41,7 +40,6 @@
"*://*.deviantart.com/*",
"activeTab",
"contextMenus",
"history",
"notifications",
"storage",
"tabs"
Expand All @@ -50,12 +48,12 @@
"pages/create-filters.html"
],
"__chrome__key": "odlmamilbohnpnoomjclomghphbajikp",
"__chrome__minimum_chrome_version": "42.0",
"__chrome__minimum_chrome_version": "49.0",
"__edge__minimum_edge_version": "33.14281.1000.0",
"__firefox__applications": {
"gecko": {
"id": "{a2ce7c11-e47d-42cf-b6db-ede36265cf6c}",
"strict_min_version": "55.0"
"strict_min_version": "62.0"
}
}
}
20 changes: 14 additions & 6 deletions app/scripts/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"es6": true,
"webextensions": true
},
"globals": {
"browser": true
},
"extends": [
"eslint:recommended",
"plugin:no-unsanitized/DOM"
"plugin:compat/recommended",
"plugin:no-unsanitized/DOM",
"plugin:react/recommended"
],
"globals": {
"browser": true
},
"parser": "babel-eslint",
"rules": {
"curly": ["error", "multi-line"],
Expand All @@ -21,8 +23,14 @@
}],
"no-useless-escape": "off",
"prefer-const": ["error"],
"semi": ["error", "always"],
"quote-props": ["error", "always"],
"quotes": ["error", "single"],
"quote-props": ["error", "always"]
"react/jsx-uses-react": 1,
"semi": ["error", "always"]
},
"settings": {
"react": {
"version": "latest"
}
}
}
8 changes: 5 additions & 3 deletions app/scripts/background/menus.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AddFilter } from './filters';
import { SendMessageToAllTabs } from './messages';
import { SHOW_FILTER_DEVIATION_MODAL } from '../constants/messages';

export const MENUS = [
Expand Down Expand Up @@ -52,8 +51,11 @@ export const OnMenuClicked = (info, tab) => {
break;

case 'show-filter-modal-deviation':
SendMessageToAllTabs(SHOW_FILTER_DEVIATION_MODAL, {
'link': info.linkUrl
browser.tabs.sendMessage(tab.id, {
'action': SHOW_FILTER_DEVIATION_MODAL,
'data': {
'link': info.linkUrl
}
});
break;

Expand Down
4 changes: 1 addition & 3 deletions app/scripts/background/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ export const OnRuntimeMessage = (message, sender) => {
case MESSAGES.FETCH_METADATA:
return fetch(new URL(`https://backend.deviantart.com/oembed?url=${message.data.url}`))
.then(response => response.json())
.catch(() => {
throw new Error(`Invalid API Response for Deviation URL: ${message.data.url}`);
});
.catch(() => Promise.reject(new Error(`Invalid API Response for Deviation URL: ${message.data.url}`)));

case MESSAGES.FETCH_CATEGORIES:
return GetCategories();
Expand Down
49 changes: 40 additions & 9 deletions app/scripts/background/runtime.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import semverClean from 'semver/functions/clean';
import semverDiff from 'semver/functions/diff';
import semverLT from 'semver/functions/lt';

import { GetCategories } from './categories';
Expand All @@ -7,13 +8,12 @@ import { ImportFilters } from './filters';
import { TAG_FILTERS_MIGRATED } from '../constants/notifications';

export const OnInstalled = ({ previousVersion, reason, temporary }) => {

// fetch and store the latest category paths
GetCategories();

if (temporary) {
// use this to simulate installs/updates for testing purposes
// previousVersion = '6.0.0';
// previousVersion = '6.1.0';
// reason = 'install';
}

Expand All @@ -40,7 +40,34 @@ const OnUpdated = async (previousVersion) => {
}
}

await ShowUpdatedPage(currentVersion, previousVersion);
let showUpdatedPageToUser = false;
try {
const releaseType = semverDiff(currentVersion, previousVersion);
if (releaseType !== null) {
const releaseTypes = await GetReleaseTypesFromOptions();
showUpdatedPageToUser = releaseTypes.includes(releaseType);
}
} catch (error) {
console.error('Failed to determine version difference on upgrade', error);
}

if (showUpdatedPageToUser) {
await ShowUpdatedPage(currentVersion, previousVersion);
}
};

const GetReleaseTypesFromOptions = async () => {
const { options } = await browser.storage.local.get('options');
const releaseType = options?.showUpdatedPageOnUpdate ?? 'patch';
const releaseTypes = [];

switch (releaseType) { /* eslint-disable no-fallthrough */
case 'patch': releaseTypes.push('patch');
case 'minor': releaseTypes.push('minor');
case 'major': releaseTypes.push('major');
}

return releaseTypes;
};

const MigrateTagFiltersToKeywordFilters = async () => {
Expand All @@ -61,13 +88,17 @@ const MigrateTagFiltersToKeywordFilters = async () => {
}
};

const ShowInstalledPage = async () => {
const url = 'https://rthaut.github.io/deviantART-Filter/installed';
await browser.tabs.create({ url });
const ShowInstalledPage = () => {
return browser.tabs.create({
'url': 'https://rthaut.github.io/deviantART-Filter/installed',
'active': true
});
};


const ShowUpdatedPage = async (currentVersion, previousVersion) => {
const url = `https://rthaut.github.io/deviantART-Filter/releases/v${currentVersion}/?from=v${previousVersion}`;
await browser.tabs.create({ url });
const ShowUpdatedPage = (currentVersion, previousVersion) => {
return browser.tabs.create({
'url': `https://rthaut.github.io/deviantART-Filter/releases/v${currentVersion}/?from=v${previousVersion}`,
'active': false
});
};
2 changes: 1 addition & 1 deletion app/scripts/content/filters/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const STORAGE_KEY = 'users';
//TODO: a VERY small portion thumbnails don't have a username available until AFTER metadata is loaded (the known case is for thumbnails of Stash items); it doesn't make sense to wait for metadata to load for all thumbnails, but having a way to re-apply this filter after metadata loads (for thumbnails that have NOT already been processed) would be useful
export const REQUIRES_METADATA = false;

const USERNAME_URL_REGEX = /([^\/]+)\/art|journal/;
const USERNAME_URL_REGEX = /([^\/]+)\/(?:art|journal|status-update)\//;

/**
* Applies filters to a given thumbnails
Expand Down
29 changes: 17 additions & 12 deletions app/scripts/create-filters/CreateFiltersApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const CreateFiltersApp = () => {
}), [darkMode]);

const [error, setError] = useState({
'help': '',
'message': '',
'error': ''
});

Expand Down Expand Up @@ -127,12 +127,11 @@ const CreateFiltersApp = () => {
reset();
}, [metadata]);

const closeModal = () => {
browser.runtime.sendMessage({
const closeModal = async () => {
await browser.runtime.sendMessage({
'action': HIDE_FILTER_DEVIATION_MODAL
}).then(() => {
reset();
});
setMetadata(null);
};

const mapCount = (obj, property) => Object.values(obj).reduce((prev, cur) => prev += cur[property], 0);
Expand All @@ -150,7 +149,7 @@ const CreateFiltersApp = () => {
setMetadata(_metadata);
} catch (error) {
setError({
'help': browser.i18n.getMessage('CreateFiltersFromDeviation_Error_FetchingMetadata'),
'message': browser.i18n.getMessage('CreateFiltersFromDeviation_Error_FetchingMetadata'),
error
});
setMetadata(null);
Expand All @@ -173,7 +172,7 @@ const CreateFiltersApp = () => {
setTitle(browser.i18n.getMessage(`CreateFiltersFromDeviation_Title_SuccessWithCount_${count == 1 ? 'Singular' : 'Plural'}`, [count]));
} catch (error) {
setError({
'help': browser.i18n.getMessage('CreateFiltersFromDeviation_Error_CreatingFilters'),
'message': browser.i18n.getMessage('CreateFiltersFromDeviation_Error_CreatingFilters'),
error
});
setResults(null);
Expand All @@ -196,11 +195,17 @@ const CreateFiltersApp = () => {

<DialogContent>

{error?.error && (<Alert severity='error'>
<AlertTitle><strong>{error.help}</strong></AlertTitle>
<Typography gutterBottom>{browser.i18n.getMessage('CreateFiltersFromDeviation_Error_Instructions')}</Typography>
<Typography component='code' variant='overline'>{error.error.message}</Typography>
</Alert>)}
{error?.message && (
<Alert severity='error'>
<AlertTitle><strong>{error.message}</strong></AlertTitle>
{error.error?.message ? (<>
<Typography variant='body1' gutterBottom>{browser.i18n.getMessage('CreateFiltersFromDeviation_Error_Instructions_HasError')}</Typography>
<Typography component='code' variant='inherit'>{error.error.message}</Typography>
</>): (
<Typography variant='body1' gutterBottom>{browser.i18n.getMessage('CreateFiltersFromDeviation_Error_Instructions')}</Typography>
)}
</Alert>
)}

{working ?
<Grid container direction='column' justify='center' alignItems='center'><CircularProgress /></Grid> : results ?
Expand Down
10 changes: 5 additions & 5 deletions app/scripts/create-filters/components/MetadataFiltersForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
NavigateNext as NavigateNextIcon,
} from '@material-ui/icons';

export const useStyles = makeStyles((theme) => ({
const useStyles = makeStyles((theme) => ({
'fieldset': {
'margin': theme.spacing(0, 0, 2),
'width': '100%',
Expand All @@ -51,10 +51,6 @@ export const useStyles = makeStyles((theme) => ({
const MetadataFiltersForm = ({ metadata, setFilter }) => {
const classes = useStyles();

if (!metadata) {
return null;
}

const [selectedUsername, setSelectedUsername] = useState('');
const [selectedTags, setSelectedTags] = useState([]);
const [selectedCategory, setSelectedCategory] = useState('');
Expand Down Expand Up @@ -108,6 +104,10 @@ const MetadataFiltersForm = ({ metadata, setFilter }) => {
}
};

if (!metadata) {
return null;
}

return (
<form noValidate>

Expand Down
4 changes: 0 additions & 4 deletions app/scripts/manage/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
Expand Down
Loading

0 comments on commit 6b85451

Please sign in to comment.