-
Notifications
You must be signed in to change notification settings - Fork 13
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 #55 from RaghavJit/main
issue 52 fixed
- Loading branch information
Showing
4 changed files
with
113 additions
and
26 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const RNFS = require('react-native-fs') | ||
import { NativeModules } from 'react-native'; | ||
|
||
const packageName = NativeModules?.AppInfo?.packageName ?? ''; | ||
const path = `${RNFS.DocumentDirectoryPath}/${packageName}/QuickTasks.json`; | ||
|
||
exports.resetJson = () => { | ||
let QuickTasks = { | ||
"Tasks": | ||
[ | ||
"sample" | ||
] | ||
} | ||
RNFS.writeFile(path, JSON.stringify(QuickTasks)); | ||
console.log(JSON.stringify(QuickTasks)) | ||
} | ||
|
||
exports.addQTask = (Tlist) => { | ||
|
||
RNFS.readFile(path) | ||
.then(value => { | ||
// Parse the JSON data | ||
const jsonData = JSON.parse(value); | ||
|
||
// Use the JSON data as needed | ||
jsonData.Tasks = Tlist | ||
|
||
RNFS.writeFile(path, JSON.stringify(jsonData)); | ||
|
||
console.log(JSON.stringify(jsonData)) | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}); | ||
|
||
} | ||
|
||
exports.getList = () => { | ||
return RNFS.readFile(path) | ||
.then(value => { | ||
// Parse the JSON data | ||
const jsonData = JSON.parse(value); | ||
console.log(jsonData) | ||
return Promise.resolve(jsonData.Tasks); | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.