mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Feature / Add working notifications with only twitter for now (#102)
* Add working notifications with only twitter for now * feat(notification-bar): I didnt copy from NP * Make default browser visibility true * feat(notifications): Collapse when no more notifications after closing one
This commit is contained in:
1 parent
11af8bfb5a
commit
40ec19a349
19 files changed
+497
-153
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import React, { createContext, useState, useEffect, useRef } from 'react';
|
||||
|
||||
export const SnackbarContext = createContext(null);
|
||||
|
||||
function SnackbarProvider({ children }) {
|
||||
const [alert, setAlert] = useState(null);
|
||||
const timer = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (alert) {
|
||||
clearTimeout(timer.current);
|
||||
timer.current = setTimeout(() => {
|
||||
setAlert(null);
|
||||
}, 1000);
|
||||
}
|
||||
return () => clearTimeout(timer.current);
|
||||
}, [alert]);
|
||||
|
||||
const addAlert = (value) => setAlert(value);
|
||||
|
||||
return (
|
||||
<SnackbarContext.Provider value={{ addAlert, alert }}>
|
||||
{children}
|
||||
</SnackbarContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export default SnackbarProvider;
|
||||
Reference in new issue
Block a user