feat: support announcement
This commit is contained in:
@@ -22,6 +22,7 @@ class App extends Component {
|
||||
load_config();
|
||||
load_attentions();
|
||||
window.AS_BACKUP = localStorage['DEFAULT_ALLOW_SEARCH'] ? true : false;
|
||||
window.LAST_ANN = localStorage['LAST_ANN'];
|
||||
listen_darkmode(
|
||||
{ default: undefined, light: false, dark: true }[
|
||||
window.config.color_scheme
|
||||
|
||||
@@ -388,3 +388,7 @@
|
||||
.root-dark-mode .box-poll .styles_votes__3IO-o {
|
||||
color: #e0e0e0 !important;
|
||||
}
|
||||
|
||||
.announcement-header {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
52
src/Flows.js
52
src/Flows.js
@@ -1283,6 +1283,38 @@ function FlowChunk(props) {
|
||||
);
|
||||
}
|
||||
|
||||
function Announcement(props) {
|
||||
const [show, setShow] = useState(true);
|
||||
function do_close() {
|
||||
window.LAST_ANN = props.text;
|
||||
localStorage['LAST_ANN'] = props.text;
|
||||
setShow(false);
|
||||
}
|
||||
return (
|
||||
show && (
|
||||
<div className="flow-item-row">
|
||||
<div className="flow-item">
|
||||
<div className="box">
|
||||
<div className="box-header announcement-header">
|
||||
<a href="###" className="no-underline" onClick={do_close}>
|
||||
|
||||
<span className="icon icon-close" />
|
||||
|
||||
</a>
|
||||
</div>
|
||||
<div className="box-content">
|
||||
<HighlightedMarkdown
|
||||
text={props.text}
|
||||
show_pid={props.show_pid}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export class Flow extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -1357,6 +1389,7 @@ class SubFlow extends PureComponent {
|
||||
title: '',
|
||||
data: [],
|
||||
},
|
||||
announcement: null,
|
||||
local_attention_text: null,
|
||||
loading_status: 'done',
|
||||
error_msg: null,
|
||||
@@ -1418,6 +1451,7 @@ class SubFlow extends PureComponent {
|
||||
),
|
||||
),
|
||||
},
|
||||
announcement: json.announcement,
|
||||
loading_status: 'done',
|
||||
}));
|
||||
})
|
||||
@@ -1597,11 +1631,14 @@ class SubFlow extends PureComponent {
|
||||
|
||||
render() {
|
||||
const should_deletion_detect = localStorage['DELETION_DETECT'] === 'on';
|
||||
const { mode, chunks, local_attention_text, search_param } = this.state;
|
||||
const { mode, chunks, local_attention_text, search_param, announcement } =
|
||||
this.state;
|
||||
const { submode, show_sidebar, token } = this.props;
|
||||
console.log(announcement);
|
||||
return (
|
||||
<div className="flow-container">
|
||||
{mode === 'attention' &&
|
||||
this.props.submode === 1 &&
|
||||
submode === 1 &&
|
||||
local_attention_text === null && (
|
||||
<button
|
||||
className="export-btn"
|
||||
@@ -1616,12 +1653,21 @@ class SubFlow extends PureComponent {
|
||||
<LocalAttentionEditer init_text={local_attention_text} />
|
||||
)}
|
||||
|
||||
{mode === 'list' &&
|
||||
announcement &&
|
||||
window.LAST_ANN !== announcement && (
|
||||
<Announcement
|
||||
text={announcement}
|
||||
show_pid={load_single_meta(show_sidebar, token)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<FlowChunk
|
||||
title={chunks.title}
|
||||
list={chunks.data}
|
||||
mode={mode}
|
||||
search_param={search_param || null}
|
||||
show_sidebar={this.props.show_sidebar}
|
||||
show_sidebar={show_sidebar}
|
||||
deletion_detect={should_deletion_detect}
|
||||
/>
|
||||
{this.state.loading_status === 'failed' && (
|
||||
|
||||
Reference in New Issue
Block a user