feat: support announcement
This commit is contained in:
@@ -22,6 +22,7 @@ class App extends Component {
|
|||||||
load_config();
|
load_config();
|
||||||
load_attentions();
|
load_attentions();
|
||||||
window.AS_BACKUP = localStorage['DEFAULT_ALLOW_SEARCH'] ? true : false;
|
window.AS_BACKUP = localStorage['DEFAULT_ALLOW_SEARCH'] ? true : false;
|
||||||
|
window.LAST_ANN = localStorage['LAST_ANN'];
|
||||||
listen_darkmode(
|
listen_darkmode(
|
||||||
{ default: undefined, light: false, dark: true }[
|
{ default: undefined, light: false, dark: true }[
|
||||||
window.config.color_scheme
|
window.config.color_scheme
|
||||||
|
|||||||
@@ -388,3 +388,7 @@
|
|||||||
.root-dark-mode .box-poll .styles_votes__3IO-o {
|
.root-dark-mode .box-poll .styles_votes__3IO-o {
|
||||||
color: #e0e0e0 !important;
|
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 {
|
export class Flow extends PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -1357,6 +1389,7 @@ class SubFlow extends PureComponent {
|
|||||||
title: '',
|
title: '',
|
||||||
data: [],
|
data: [],
|
||||||
},
|
},
|
||||||
|
announcement: null,
|
||||||
local_attention_text: null,
|
local_attention_text: null,
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
error_msg: null,
|
error_msg: null,
|
||||||
@@ -1418,6 +1451,7 @@ class SubFlow extends PureComponent {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
announcement: json.announcement,
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
}));
|
}));
|
||||||
})
|
})
|
||||||
@@ -1597,11 +1631,14 @@ class SubFlow extends PureComponent {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const should_deletion_detect = localStorage['DELETION_DETECT'] === 'on';
|
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 (
|
return (
|
||||||
<div className="flow-container">
|
<div className="flow-container">
|
||||||
{mode === 'attention' &&
|
{mode === 'attention' &&
|
||||||
this.props.submode === 1 &&
|
submode === 1 &&
|
||||||
local_attention_text === null && (
|
local_attention_text === null && (
|
||||||
<button
|
<button
|
||||||
className="export-btn"
|
className="export-btn"
|
||||||
@@ -1616,12 +1653,21 @@ class SubFlow extends PureComponent {
|
|||||||
<LocalAttentionEditer init_text={local_attention_text} />
|
<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
|
<FlowChunk
|
||||||
title={chunks.title}
|
title={chunks.title}
|
||||||
list={chunks.data}
|
list={chunks.data}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
search_param={search_param || null}
|
search_param={search_param || null}
|
||||||
show_sidebar={this.props.show_sidebar}
|
show_sidebar={show_sidebar}
|
||||||
deletion_detect={should_deletion_detect}
|
deletion_detect={should_deletion_detect}
|
||||||
/>
|
/>
|
||||||
{this.state.loading_status === 'failed' && (
|
{this.state.loading_status === 'failed' && (
|
||||||
|
|||||||
Reference in New Issue
Block a user