diff --git a/web/app/common/constants.js b/web/app/common/constants.js index a526c2c7..5301d7ae 100644 --- a/web/app/common/constants.js +++ b/web/app/common/constants.js @@ -43,7 +43,7 @@ export const BLOCKING_DURATIONS = [ * Defines if browser storage features (cookies, localsrotage) * are available or blocked via browser preferences */ -export const STORAGE_AVAILABLE = (() => { +export const IS_STORAGE_AVAILABLE = (() => { try { localStorage.setItem('localstorage_availability_test', null); localStorage.removeItem('localstorage_availability_test'); diff --git a/web/app/common/localStorage.js b/web/app/common/localStorage.js index 417f7dc4..4de98c09 100644 --- a/web/app/common/localStorage.js +++ b/web/app/common/localStorage.js @@ -1,12 +1,4 @@ -export const isAvailable = (() => { - try { - localStorage.setItem('localstorage_availability_test', null); - localStorage.removeItem('localstorage_availability_test'); - } catch (e) { - return false; - } - return true; -})(); +import { isAvailable } from 'common/constants'; const failMessage = 'remark42: localStorage access denied, check browser preferences'; diff --git a/web/app/components/auth-panel/auth-panel.jsx b/web/app/components/auth-panel/auth-panel.jsx index 1cc5ef76..0926ddef 100644 --- a/web/app/components/auth-panel/auth-panel.jsx +++ b/web/app/components/auth-panel/auth-panel.jsx @@ -4,7 +4,7 @@ import { h, Component } from 'preact'; import UserId from './__user-id/auth-panel__user-id'; import Dropdown, { DropdownItem } from 'components/dropdown'; import Button from 'components/button'; -import { PROVIDER_NAMES, STORAGE_AVAILABLE, IS_THIRD_PARTY } from 'common/constants'; +import { PROVIDER_NAMES, IS_STORAGE_AVAILABLE, IS_THIRD_PARTY } from 'common/constants'; import { requestDeletion } from 'utils/email'; import { getHandleClickProps } from 'common/accessibility'; @@ -76,7 +76,7 @@ export default class AuthPanel extends Component { )} - {STORAGE_AVAILABLE && + {IS_STORAGE_AVAILABLE && !loggedIn && (
Sign in to comment using{' '} @@ -100,7 +100,7 @@ export default class AuthPanel extends Component {
)} - {!STORAGE_AVAILABLE && + {!IS_STORAGE_AVAILABLE && IS_THIRD_PARTY && (
Disable third-party cookies blocking to sign in or open comments in{' '} @@ -114,7 +114,7 @@ export default class AuthPanel extends Component {
)} - {!STORAGE_AVAILABLE && + {!IS_STORAGE_AVAILABLE && !IS_THIRD_PARTY &&
Allow cookies to sign in and comment
}
diff --git a/web/app/components/thread/getCollapsedComments.js b/web/app/components/thread/getCollapsedComments.js index b240a8b5..a239b0fa 100644 --- a/web/app/components/thread/getCollapsedComments.js +++ b/web/app/components/thread/getCollapsedComments.js @@ -1,6 +1,6 @@ import { LS_COLLAPSE_KEY } from 'common/constants'; -import { getItem } from 'common/localStorage'; +import { getItem as localStorageGetItem } from 'common/localStorage'; -const getCollapsedComments = () => JSON.parse(getItem(LS_COLLAPSE_KEY) || '[]'); +const getCollapsedComments = () => JSON.parse(localStorageGetItem(LS_COLLAPSE_KEY) || '[]'); export default getCollapsedComments; diff --git a/web/app/components/thread/saveCollapsedComments.js b/web/app/components/thread/saveCollapsedComments.js index bb2da2de..53b29b62 100644 --- a/web/app/components/thread/saveCollapsedComments.js +++ b/web/app/components/thread/saveCollapsedComments.js @@ -1,6 +1,6 @@ import { LS_COLLAPSE_KEY } from 'common/constants'; -import { setItem } from 'common/localStorage'; +import { setItem as localStorageSetItem } from 'common/localStorage'; -const saveCollapsedComments = comments => setItem(LS_COLLAPSE_KEY, JSON.stringify(comments)); +const saveCollapsedComments = comments => localStorageSetItem(LS_COLLAPSE_KEY, JSON.stringify(comments)); export default saveCollapsedComments; diff --git a/web/comments.ejs b/web/comments.ejs index dbd08fc9..1b1ced18 100644 --- a/web/comments.ejs +++ b/web/comments.ejs @@ -39,8 +39,8 @@ titleElement.innerHTML = '

Comments for '+query.url+'

' var remark_config = { - site_id: 'remark', - url: 'https://remark42.com/demo/', + site_id: query.site_id, + url: query.url, }; (function () {