some change
This commit is contained in:
1 parent
7abf0bafa5
commit
e9a4550070
10 files changed
+17
-78
No files matched your search
@@ -2,3 +2,5 @@ node_modules
|
||||
/build
|
||||
/*.log
|
||||
/.idea
|
||||
|
||||
deploy.sh
|
||||
@@ -0,0 +1 @@
|
||||
[{"timestamp":1641758728691,"files":[{"filename":"bundle.*****.esm.js","previous":10239,"size":10239,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":11058,"size":11059,"diff":1},{"filename":"sw.js","previous":11053,"size":11054,"diff":1},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1750,"size":1750,"diff":0},{"filename":"200.html","previous":906,"size":907,"diff":1},{"filename":"bundle.cf62b.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.dfe9a.js","previous":10877,"size":0,"diff":-10877},{"filename":"bundle.08aea.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.ec582.js","previous":0,"size":10878,"diff":10878}]},{"timestamp":1641758670087,"files":[{"filename":"bundle.*****.esm.js","previous":10239,"size":10239,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":1001,"size":11058,"diff":10057},{"filename":"sw.js","previous":996,"size":11053,"diff":10057},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1750,"size":1750,"diff":0},{"filename":"200.html","previous":907,"size":906,"diff":-1},{"filename":"bundle.ae28f.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.573ad.js","previous":10878,"size":0,"diff":-10878},{"filename":"bundle.cf62b.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.dfe9a.js","previous":0,"size":10877,"diff":10877}]},{"timestamp":1641758343936,"files":[{"filename":"bundle.*****.esm.js","previous":10283,"size":10239,"diff":-44},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":1001,"size":1001,"diff":0},{"filename":"sw.js","previous":996,"size":996,"diff":0},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1752,"size":1750,"diff":-2},{"filename":"200.html","previous":909,"size":907,"diff":-2},{"filename":"bundle.c150a.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.d96b4.js","previous":10914,"size":0,"diff":-10914},{"filename":"bundle.ae28f.css","previous":0,"size":2729,"diff":2729},{"filename":"bundle.573ad.js","previous":0,"size":10878,"diff":10878}]},{"timestamp":1641757866099,"files":[{"filename":"bundle.*****.esm.js","previous":10283,"size":10283,"diff":0},{"filename":"polyfills.*****.esm.js","previous":2191,"size":2191,"diff":0},{"filename":"route-Home.chunk.*****.esm.js","previous":5212,"size":5212,"diff":0},{"filename":"route-Plant.chunk.*****.esm.js","previous":5866,"size":5866,"diff":0},{"filename":"route-Profile.chunk.*****.esm.js","previous":922,"size":922,"diff":0},{"filename":"sw-esm.js","previous":11014,"size":1001,"diff":-10013},{"filename":"sw.js","previous":11008,"size":996,"diff":-10012},{"filename":"polyfills.03377.js","previous":2291,"size":2291,"diff":0},{"filename":"route-Home.chunk.05537.js","previous":5725,"size":5725,"diff":0},{"filename":"route-Plant.chunk.562c8.js","previous":6400,"size":6400,"diff":0},{"filename":"route-Profile.chunk.5b010.js","previous":1393,"size":1393,"diff":0},{"filename":"index.html","previous":1753,"size":1752,"diff":-1},{"filename":"200.html","previous":909,"size":909,"diff":0},{"filename":"bundle.5f895.css","previous":2729,"size":0,"diff":-2729},{"filename":"bundle.624b3.js","previous":10914,"size":0,"diff":-10914},{"filename":"bundle.c150a.css","previous":0,"siLine truncated
|
||||
+2
-8
@@ -1,11 +1,10 @@
|
||||
import { createContext } from "preact";
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import usePlants from "./hooks/PlantsHook";
|
||||
import { useLocalStorage } from "./hooks/LocalStorageHook"
|
||||
import useUser from "./hooks/UserHook";
|
||||
|
||||
export const UserContext = createContext()
|
||||
export const PlantsContext = createContext()
|
||||
export const UserContext = createContext(null)
|
||||
export const PlantsContext = createContext(null)
|
||||
|
||||
export default function ContextsProviders({children}) {
|
||||
|
||||
@@ -13,11 +12,6 @@ export default function ContextsProviders({children}) {
|
||||
const [user, setUser] = useUser(data, setData)
|
||||
const {plants, addPlant, editPlant, removePlant, addAction, doneTask, history} = usePlants(data, setData)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
console.log('first', user);
|
||||
}, [user])
|
||||
|
||||
return <UserContext.Provider value={[user, setUser]}>
|
||||
<PlantsContext.Provider value={{plants, addPlant, editPlant, removePlant, addAction, doneTask, history}}>
|
||||
{children}
|
||||
|
||||
@@ -12,13 +12,13 @@ import {useEffect} from "preact/hooks";
|
||||
|
||||
const App = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!Notification) {
|
||||
alert('Le navigateur ne supporte pas les notifications.');
|
||||
} else if (Notification.permission !== 'granted') {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
}, [])
|
||||
// useEffect(() => {
|
||||
// if (!Notification) {
|
||||
// alert('Le navigateur ne supporte pas les notifications.');
|
||||
// } else if (Notification.permission !== 'granted') {
|
||||
// Notification.requestPermission();
|
||||
// }
|
||||
// }, [])
|
||||
|
||||
return (
|
||||
<div id="app" class="h-screen overflow-auto flex flex-col">
|
||||
|
||||
@@ -3,7 +3,6 @@ import {route} from "preact-router";
|
||||
|
||||
const usePlants = (data, setData) => {
|
||||
const [plants, setPlants] = useState([])
|
||||
const [tasks, setTasks] = useState([])
|
||||
|
||||
useEffect(() =>{
|
||||
setPlants(data.plants ?? [])
|
||||
@@ -32,9 +31,7 @@ const usePlants = (data, setData) => {
|
||||
|
||||
const addAction = (plant, action) => {
|
||||
action.id = action.action_type + '-' + plant.id
|
||||
let plantIndex = plants.findIndex(item => item.id === plant.id)
|
||||
let actionIndex = plant.actions.findIndex(item => item.action_type === action.action_type)
|
||||
console.log(actionIndex, plantIndex, plant, plants, action)
|
||||
actionIndex >= 0 ? plant.actions[actionIndex] = action
|
||||
: plant.actions.push(action)
|
||||
editPlant(plant)
|
||||
|
||||
@@ -6,7 +6,6 @@ const useUser = (data, setData) => {
|
||||
|
||||
useEffect(() =>{
|
||||
setData({...data, user: user})
|
||||
console.log('in', user);
|
||||
document.querySelector('html').classList.toggle('dark', user.dark_mode)
|
||||
}, [user])
|
||||
|
||||
|
||||
+2
-4
@@ -11,13 +11,11 @@ import {Tasks} from "../components/Tasks"
|
||||
export const Home = () => {
|
||||
const [addModal, setAddModal] = useState(false)
|
||||
const [plantForm, setPlantForm] = useState({})
|
||||
const app = document.getElementById("app")
|
||||
const { plants, addPlant } = useContext(PlantsContext)
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
console.log(plantForm)
|
||||
addPlant(plantForm)
|
||||
setAddModal(false)
|
||||
}
|
||||
@@ -47,7 +45,7 @@ export const Home = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{createPortal(
|
||||
{typeof window !== "undefined" && createPortal(
|
||||
<Modal isOpen={addModal} onChange={handleCloseAddModal}>
|
||||
<ModalTitle>
|
||||
Add Plant
|
||||
@@ -62,7 +60,7 @@ export const Home = () => {
|
||||
</Button>
|
||||
</form>
|
||||
</Modal>,
|
||||
app
|
||||
document.getElementById('app')
|
||||
)}
|
||||
</PageLayout>
|
||||
)
|
||||
|
||||
@@ -37,7 +37,6 @@ const Plant = ({id}) => {
|
||||
if (!actionForm.action_type) {
|
||||
actionForm.action_type = action_types[0]
|
||||
}
|
||||
console.log("my event", e, actionForm)
|
||||
addAction(plant, actionForm)
|
||||
setAddModal(false)
|
||||
}
|
||||
|
||||
@@ -1,55 +1,3 @@
|
||||
import { getFiles, setupPrecaching, setupRouting } from 'preact-cli/sw/';
|
||||
import { setupRouting } from 'preact-cli/sw'
|
||||
|
||||
setupRouting();
|
||||
setupPrecaching(getFiles());
|
||||
|
||||
function wait(ms) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(resolve, ms);
|
||||
});
|
||||
}
|
||||
|
||||
const BASE = location.protocol + '//' + location.host
|
||||
const PREFIX = "V1"
|
||||
const CACHED_FILES = [
|
||||
`${BASE}/sw.js`,
|
||||
`${BASE}/js/app.js`,
|
||||
`${BASE}/css/app.css`,
|
||||
`${BASE}/offline.html`,
|
||||
]
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
self.skipWaiting()
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const cache = await caches.open(PREFIX)
|
||||
await cache.addAll(CACHED_FILES)
|
||||
})()
|
||||
)
|
||||
console.log(`${PREFIX} Install`)
|
||||
})
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
clients.claim()
|
||||
event.waitUntil((async() => {
|
||||
const keys = await caches.keys()
|
||||
await Promise.all(
|
||||
keys.map(key => {
|
||||
if (!key.includes(PREFIX)) {
|
||||
return caches.delete(key)
|
||||
}
|
||||
})
|
||||
)
|
||||
})())
|
||||
console.log(`${PREFIX} Activate`)
|
||||
})
|
||||
|
||||
const delay = 1000 * 60 * 60 * 24
|
||||
|
||||
console.log(localStorage.getItem('data'))
|
||||
|
||||
wait(delay)
|
||||
.then(() => {
|
||||
// do thing
|
||||
|
||||
}).catch(err => console.log(err))
|
||||
setupRouting()
|
||||
@@ -11,5 +11,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<% preact.bodyEnd %>
|
||||
<script src="sw.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user