feat: prepare for push notification

This commit is contained in:
2022-08-13 18:05:04 +08:00
parent 7df8b39061
commit c1431ba051
6 changed files with 105 additions and 29 deletions

View File

@@ -9,6 +9,7 @@ import {
ClickHandler,
ColoredSpan,
HighlightedMarkdown,
get_push_subscription,
} from './Common';
import './Flows.css';
import LazyLoad, { forceCheck } from 'react-lazyload';
@@ -749,6 +750,29 @@ class FlowSidebar extends PureComponent {
</a>
</span>
)}
{!!this.props.token && !!this.state.attention && (
<span>
<a
href="###"
style={{ display: 'none' }}
onClick={() => {
console.log('set notifi');
get_push_subscription().then((sc) => {
if (!sc) return;
fetch('/_test', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(sc),
});
});
}}
>
<span className="icon icon-star">提醒</span>
</a>
</span>
)}
</div>
{!!this.state.filter_name && (
<div className="box box-tip flow-item filter-name-bar">