|
@@ -9,6 +9,7 @@ import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
|
|
import { TwitterApiProvider } from "../../providers/twitter-api/twitter-api";
|
|
|
import { HttpClient } from "@angular/common/http";
|
|
|
import { Storage } from "@ionic/storage";
|
|
|
+import Gun from "gun";
|
|
|
|
|
|
/**
|
|
|
* Generated class for the WriteTweetPage page.
|
|
@@ -24,6 +25,7 @@ import { Storage } from "@ionic/storage";
|
|
|
})
|
|
|
export class WriteTweetPage {
|
|
|
tweet: FormGroup;
|
|
|
+ gun;
|
|
|
|
|
|
constructor(
|
|
|
public navCtrl: NavController,
|
|
@@ -34,6 +36,7 @@ export class WriteTweetPage {
|
|
|
private http: HttpClient,
|
|
|
private storage: Storage
|
|
|
) {
|
|
|
+ this.gun = Gun();
|
|
|
this.tweet = this.formBuilder.group({
|
|
|
text: ["", Validators.maxLength(140)],
|
|
|
p2p: [false]
|
|
@@ -54,7 +57,8 @@ export class WriteTweetPage {
|
|
|
loading.present();
|
|
|
|
|
|
if (this.tweet.value.p2p) {
|
|
|
- await this.postToIpfs(this.tweet.value["text"]);
|
|
|
+ let hash = await this.postToIpfs(this.tweet.value["text"]);
|
|
|
+ this.gun.get("username").put({ lastTweet: hash });
|
|
|
} else {
|
|
|
await this.twitter.tweet(this.tweet.value["text"]);
|
|
|
}
|
|
@@ -77,5 +81,6 @@ export class WriteTweetPage {
|
|
|
|
|
|
let res = await this.http.post(url, formData).toPromise();
|
|
|
console.log(res["Hash"]);
|
|
|
+ return res["Hash"];
|
|
|
}
|
|
|
}
|