-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #755 from friendsofagape/fix/Project-A-B-resource-…
…issue Fix Issue #728
- Loading branch information
Showing
4 changed files
with
203 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AutographaContext } from '@/components/context/AutographaContext'; | ||
import moment from 'moment'; | ||
import { useContext } from 'react'; | ||
import localforage from 'localforage'; | ||
|
||
export default function useAddNotification() { | ||
const { | ||
action: { | ||
setNotifications, | ||
}, | ||
} = useContext(AutographaContext); | ||
|
||
const addNotification = async (title, text, type) => { | ||
localforage.getItem('notification').then((value) => { | ||
const temp = [...value]; | ||
temp.push({ | ||
title, | ||
text, | ||
type, | ||
time: moment().format(), | ||
hidden: true, | ||
}); | ||
setNotifications(temp); | ||
}); | ||
}; | ||
|
||
return { addNotification }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import localforage from 'localforage'; | ||
|
||
function isBackendProjectExist(ProjectDir) { | ||
const newpath = localStorage.getItem('userPath'); | ||
const fs = window.require('fs'); | ||
const path = require('path'); | ||
// Step1 : check the project Dir and Meta exist | ||
// step2 : exist return True | ||
return new Promise((resolve) => { | ||
// let checkStatus = false; | ||
localforage.getItem('userProfile').then((value) => { | ||
if (value?.username) { | ||
const resourcePath = path.join(newpath, 'autographa', 'users', value.username, 'resources', ProjectDir); | ||
// check for path exist or not and resolve true or false will work for pane 1 now add for other panes | ||
if (fs.existsSync(resourcePath) && fs.existsSync(path.join(resourcePath, 'metadata.json'))) { | ||
resolve(true); | ||
} else { | ||
resolve(false); | ||
} | ||
} else { | ||
resolve(false); | ||
} | ||
}); | ||
}); | ||
} | ||
export default isBackendProjectExist; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters