kopia lustrzana https://github.com/cheeaun/phanpy
commit
98e6a6e42e
|
@ -133,7 +133,14 @@ const SCAN_RE = new RegExp(
|
|||
|
||||
function highlightText(text, { maxCharacters = Infinity }) {
|
||||
// Accept text string, return formatted HTML string
|
||||
let html = text;
|
||||
// Escape all HTML special characters
|
||||
let html = text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
|
||||
// Exceeded characters limit
|
||||
const { composerCharacterCount } = states;
|
||||
let leftoverHTML = '';
|
||||
|
|
|
@ -1271,12 +1271,20 @@ function Status({
|
|||
}`}
|
||||
onMouseEnter={debugHover}
|
||||
onContextMenu={(e) => {
|
||||
// FIXME: this code isn't getting called on Chrome at all?
|
||||
if (!showContextMenu) return;
|
||||
if (e.metaKey) return;
|
||||
// console.log('context menu', e);
|
||||
const link = e.target.closest('a');
|
||||
if (link && /^https?:\/\//.test(link.getAttribute('href'))) return;
|
||||
|
||||
// If there's selected text, don't show custom context menu
|
||||
const selection = window.getSelection?.();
|
||||
if (selection.toString().length > 0) {
|
||||
const { anchorNode } = selection;
|
||||
if (statusRef.current?.contains(anchorNode)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
e.preventDefault();
|
||||
setContextMenuProps({
|
||||
anchorPoint: {
|
||||
|
|
|
@ -643,7 +643,7 @@ function PushNotificationsSection({ onClose }) {
|
|||
const { instance } = api();
|
||||
const [uiState, setUIState] = useState('default');
|
||||
const pushFormRef = useRef();
|
||||
const [allowNofitications, setAllowNotifications] = useState(false);
|
||||
const [allowNotifications, setAllowNotifications] = useState(false);
|
||||
const [needRelogin, setNeedRelogin] = useState(false);
|
||||
const previousPolicyRef = useRef();
|
||||
useEffect(() => {
|
||||
|
@ -689,7 +689,7 @@ function PushNotificationsSection({ onClose }) {
|
|||
ref={pushFormRef}
|
||||
onChange={() => {
|
||||
const values = Object.fromEntries(new FormData(pushFormRef.current));
|
||||
const allowNofitications = !!values['policy-allow'];
|
||||
const allowNotifications = !!values['policy-allow'];
|
||||
const params = {
|
||||
policy: values.policy,
|
||||
data: {
|
||||
|
@ -718,9 +718,13 @@ function PushNotificationsSection({ onClose }) {
|
|||
});
|
||||
const policyChanged = previousPolicyRef.current !== params.policy;
|
||||
|
||||
console.log('PN Form', { values, allowNofitications, params });
|
||||
console.log('PN Form', {
|
||||
values,
|
||||
allowNotifications: allowNotifications,
|
||||
params,
|
||||
});
|
||||
|
||||
if (allowNofitications && alertsCount > 0) {
|
||||
if (allowNotifications && alertsCount > 0) {
|
||||
if (policyChanged) {
|
||||
console.debug('Policy changed.');
|
||||
removeSubscription()
|
||||
|
@ -754,7 +758,7 @@ function PushNotificationsSection({ onClose }) {
|
|||
type="checkbox"
|
||||
disabled={isLoading || needRelogin}
|
||||
name="policy-allow"
|
||||
checked={allowNofitications}
|
||||
checked={allowNotifications}
|
||||
onChange={async (e) => {
|
||||
const { checked } = e.target;
|
||||
if (checked) {
|
||||
|
@ -778,7 +782,7 @@ function PushNotificationsSection({ onClose }) {
|
|||
Allow from{' '}
|
||||
<select
|
||||
name="policy"
|
||||
disabled={isLoading || needRelogin || !allowNofitications}
|
||||
disabled={isLoading || needRelogin || !allowNotifications}
|
||||
>
|
||||
{[
|
||||
{
|
||||
|
@ -803,7 +807,7 @@ function PushNotificationsSection({ onClose }) {
|
|||
style={{
|
||||
width: '100%',
|
||||
}}
|
||||
hidden={!allowNofitications}
|
||||
hidden={!allowNotifications}
|
||||
>
|
||||
<div class="shazam-container-inner">
|
||||
<div class="sub-section">
|
||||
|
|
Ładowanie…
Reference in New Issue