Changed sync syntax and removed uncessary function
This commit is contained in:
parent
faa33a5655
commit
e8b010a3c5
2 changed files with 31 additions and 41 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "obsidian-habitica-integration",
|
"id": "obsidian-habitica-integration",
|
||||||
"name": "Habitica Sync",
|
"name": "Habitica Sync",
|
||||||
"version": "0.9.6",
|
"version": "0.9.7",
|
||||||
"minAppVersion": "0.9.12",
|
"minAppVersion": "0.9.12",
|
||||||
"description": "This plugin helps integrate Habitica user tasks and stats into Obsidian",
|
"description": "This plugin helps integrate Habitica user tasks and stats into Obsidian",
|
||||||
"author": "Leoh and Ran",
|
"author": "Leoh and Ran",
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import { getStats, scoreTask } from "./habiticaAPI"
|
||||||
import Statsview from "./Components/Statsview"
|
import Statsview from "./Components/Statsview"
|
||||||
import Taskview from "./Components/Taskview"
|
import Taskview from "./Components/Taskview"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class App extends React.Component<any,any> {
|
class App extends React.Component<any,any> {
|
||||||
username = ""
|
username = ""
|
||||||
credentials = ""
|
credentials = ""
|
||||||
|
|
@ -33,53 +31,45 @@ class App extends React.Component<any,any> {
|
||||||
this.handleChangeHabits = this.handleChangeHabits.bind(this)
|
this.handleChangeHabits = this.handleChangeHabits.bind(this)
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
sendNotice(message: string){
|
|
||||||
new Notice(message)
|
|
||||||
}
|
}
|
||||||
async reloadData() {
|
async reloadData() {
|
||||||
const result = (await getStats(this.username, this.credentials)).json()
|
try {
|
||||||
result.then(
|
let response = await getStats(this.username, this.credentials);
|
||||||
result => {
|
let result = await response.json();
|
||||||
if (result.success === false) {
|
if (result.success === false) {
|
||||||
this.sendNotice("Login Failed, Please check this.credentials and try again!")
|
new Notice('Login Failed, Please check credentials and try again!');
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
this.setState({
|
this.setState({
|
||||||
isLoaded: true,
|
isLoaded: true,
|
||||||
user_data: result,
|
user_data: result,
|
||||||
tasks: result.tasks,
|
tasks: result.tasks,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
},
|
} catch (e) {
|
||||||
(error) => {
|
console.log(e);
|
||||||
this.setState({
|
new Notice("API Error: Please check credentials")
|
||||||
isLoaded: true,
|
|
||||||
error
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.reloadData()
|
this.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendScore(id:string , score: string, message: string){
|
async sendScore(id:string , score: string, message: string){
|
||||||
const result = (await scoreTask(this.username, this.credentials, id, score)).json()
|
try {
|
||||||
result.then(
|
let response = await scoreTask(this.username, this.credentials, id, score);
|
||||||
result => {
|
let result = await response.json();
|
||||||
if(result.success) {
|
if(result.success === true){
|
||||||
this.sendNotice(message)
|
new Notice(message);
|
||||||
this.reloadData()
|
this.reloadData();
|
||||||
} else {
|
} else {
|
||||||
this.sendNotice("Resyncing, please try again")
|
new Notice("Resyncing, please try again");
|
||||||
this.reloadData()
|
this.reloadData();
|
||||||
}
|
}
|
||||||
},
|
} catch (e) {
|
||||||
(error) => {
|
console.log(e);
|
||||||
this.sendNotice("API Error: Please Check crendentials and try again")
|
new Notice("API Error: Please check credentials")
|
||||||
console.log(error)
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChangeTodos(event: any){
|
handleChangeTodos(event: any){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue