mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(quotes): resolve external quote links across boards (#1064)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface ExternalQuoteStatusState {
|
||||
message: string | null;
|
||||
clearStatus: () => void;
|
||||
setErrorStatus: (message: string) => void;
|
||||
}
|
||||
|
||||
let hideTimeout: number | null = null;
|
||||
|
||||
const clearHideTimeout = () => {
|
||||
if (hideTimeout !== null) {
|
||||
window.clearTimeout(hideTimeout);
|
||||
hideTimeout = null;
|
||||
}
|
||||
};
|
||||
|
||||
const scheduleHide = (clearStatus: () => void, delayMs: number) => {
|
||||
clearHideTimeout();
|
||||
hideTimeout = window.setTimeout(() => {
|
||||
clearStatus();
|
||||
}, delayMs);
|
||||
};
|
||||
|
||||
const useExternalQuoteStatusStore = create<ExternalQuoteStatusState>((set, get) => ({
|
||||
message: null,
|
||||
clearStatus: () => {
|
||||
clearHideTimeout();
|
||||
set({ message: null });
|
||||
},
|
||||
setErrorStatus: (message: string) => {
|
||||
set({ message });
|
||||
scheduleHide(get().clearStatus, 4000);
|
||||
},
|
||||
}));
|
||||
|
||||
export default useExternalQuoteStatusStore;
|
||||
Reference in New Issue
Block a user