feat: display memo with updated ts (#1760)

This commit is contained in:
boojack
2023-05-28 01:50:09 +08:00
committed by GitHub
parent 826541a714
commit e0e59c5831
19 changed files with 82 additions and 47 deletions

View File

@ -17,6 +17,7 @@ interface State {
additionalStyle: string;
additionalScript: string;
maxUploadSizeMiB: number;
memoDisplayWithUpdatedTs: boolean;
}
const SystemSection = () => {
@ -31,6 +32,7 @@ const SystemSection = () => {
additionalScript: systemStatus.additionalScript,
disablePublicMemos: systemStatus.disablePublicMemos,
maxUploadSizeMiB: systemStatus.maxUploadSizeMiB,
memoDisplayWithUpdatedTs: systemStatus.memoDisplayWithUpdatedTs,
});
const [telegramRobotToken, setTelegramRobotToken] = useState<string>("");
const [openAIConfig, setOpenAIConfig] = useState<OpenAIConfig>({
@ -65,6 +67,7 @@ const SystemSection = () => {
additionalScript: systemStatus.additionalScript,
disablePublicMemos: systemStatus.disablePublicMemos,
maxUploadSizeMiB: systemStatus.maxUploadSizeMiB,
memoDisplayWithUpdatedTs: systemStatus.memoDisplayWithUpdatedTs,
});
}, [systemStatus]);
@ -202,6 +205,18 @@ const SystemSection = () => {
});
};
const handleMemoDisplayWithUpdatedTs = async (value: boolean) => {
setState({
...state,
memoDisplayWithUpdatedTs: value,
});
globalStore.setSystemStatus({ disablePublicMemos: value });
await api.upsertSystemSetting({
name: "memo-display-with-updated-ts",
value: JSON.stringify(value),
});
};
const handleMaxUploadSizeChanged = async (event: React.FocusEvent<HTMLInputElement>) => {
// fixes cursor skipping position on mobile
event.target.selectionEnd = event.target.value.length;
@ -254,6 +269,10 @@ const SystemSection = () => {
<span className="normal-text">{t("setting.system-section.disable-public-memos")}</span>
<Switch checked={state.disablePublicMemos} onChange={(event) => handleDisablePublicMemosChanged(event.target.checked)} />
</div>
<div className="form-label">
<span className="normal-text">Display with updated time</span>
<Switch checked={state.memoDisplayWithUpdatedTs} onChange={(event) => handleMemoDisplayWithUpdatedTs(event.target.checked)} />
</div>
<div className="form-label">
<div className="flex flex-row items-center">
<span className="text-sm mr-1">{t("setting.system-section.max-upload-size")}</span>