diff --git a/AllTranslationAssets.ts b/AllTranslationAssets.ts
index 6ab854079..b2abe6a85 100644
--- a/AllTranslationAssets.ts
+++ b/AllTranslationAssets.ts
@@ -135,7 +135,8 @@ export default class AllTranslationAssets {
affiliated_reviewer_warning: new Translation( {"en":"(Affiliated review)","nl":"(Review door betrokkene)"} ),
saving_review: new Translation( {"en":"Saving...","nl":"Opslaan..."} ),
saved: new Translation( {"en":"Review saved. Thanks for sharing!","nl":"Bedankt om je beoordeling te delen!"} ),
- attribution: new Translation( {"en":"Reviews are powered by Mangrove Reviews and are available under CC-BY 4.0","nl":"De beoordelingen worden voorzien door Mangrove Reviews en zijn beschikbaar onder deCC-BY 4.0-licentie "} ),
+ tos: new Translation( {"en":"If you create a review, you agree to the TOS and privacy policy of Mangrove.reviews","nl":"Als je je review publiceert, ga je akkoord met de de gebruiksvoorwaarden en privacy policy van Mangrove.reviews"} ),
+ attribution: new Translation( {"en":"Reviews are powered by Mangrove Reviews and are available under CC-BY 4.0.","nl":"De beoordelingen worden voorzien door Mangrove Reviews en zijn beschikbaar onder deCC-BY 4.0-licentie. "} ),
plz_login: new Translation( {"en":"Login to leave a review","nl":"Meld je aan om een beoordeling te geven"} ),
},
}}
\ No newline at end of file
diff --git a/Logic/Web/MangroveReviews.ts b/Logic/Web/MangroveReviews.ts
index 2e6ec4c00..5990c8792 100644
--- a/Logic/Web/MangroveReviews.ts
+++ b/Logic/Web/MangroveReviews.ts
@@ -13,6 +13,7 @@ export class MangroveIdentity {
if (str === undefined || str === "") {
return;
}
+ console.log("JWK ", JSON.parse(str));
mangrove.jwkToKeypair(JSON.parse(str)).then(keypair => {
self.keypair = keypair;
console.log("Identity loaded")
@@ -113,15 +114,24 @@ export default class MangroveReviews {
mangrove.getReviews({sub: this.GetSubjectUri()}).then(
(data) => {
const reviews = [];
+ const reviewsByUser = [];
for (const review of data.reviews) {
const r = review.payload;
- reviews.push({
+ console.log("PublicKey is ",self._mangroveIdentity.keypair, "reviews is",review.signature);
+ const byUser = self._mangroveIdentity.keypair.publicKey === review.signature;
+ console.log("IS SAME: ", byUser);
+ const rev: Review = {
+ made_by_user: byUser,
date: new Date(r.iat * 1000),
comment: r.opinion,
author: r.metadata.nickname,
affiliated: r.metadata.is_affiliated,
rating: r.rating // percentage points
- })
+ };
+
+
+
+ (rev.made_by_user ? reviewsByUser : reviews).push(rev);
}
self._reviews.setData(reviews)
}
@@ -141,18 +151,37 @@ export default class MangroveReviews {
rating: r.rating,
opinion: r.comment,
metadata: {
- is_affiliated: r.affiliated,
nickname: r.author,
}
};
- if (this._dryRun) {
- console.log("DRYRUNNING mangrove reviews: ", payload);
- } else {
- mangrove.signAndSubmitReview(this._mangroveIdentity.keypair, payload).then(callback)
+ if (r.affiliated) {
+ // @ts-ignore
+ payload.metadata.is_affiliated = true;
}
- this._reviews.data.push(r);
- this._reviews.ping();
- callback();
+ if (this._dryRun) {
+ console.warn("DRYRUNNING mangrove reviews: ", payload);
+ if (callback) {
+ if (callback) {
+ console.log("Calling callback")
+ callback();
+ }
+ this._reviews.data.push(r);
+ this._reviews.ping();
+
+ }
+ } else {
+ mangrove.signAndSubmitReview(this._mangroveIdentity.keypair, payload).then(() => {
+ if (callback) {
+ console.log("Calling callback")
+ callback();
+ }
+ this._reviews.data.push(r);
+ this._reviews.ping();
+
+ })
+ }
+
+
}
diff --git a/Logic/Web/Review.ts b/Logic/Web/Review.ts
index 24f397a12..8c037dd25 100644
--- a/Logic/Web/Review.ts
+++ b/Logic/Web/Review.ts
@@ -3,5 +3,9 @@ export interface Review {
author: string,
date: Date,
rating: number,
- affiliated: boolean
+ affiliated: boolean,
+ /**
+ * True if the current logged in user is the creator of this comment
+ */
+ made_by_user: boolean
}
\ No newline at end of file
diff --git a/State.ts b/State.ts
index 17b41b597..a84847fa5 100644
--- a/State.ts
+++ b/State.ts
@@ -24,7 +24,7 @@ export default class State {
// The singleton of the global state
public static state: State;
- public static vNumber = "0.2.5-rc1";
+ public static vNumber = "0.2.5-rc2";
// The user journey states thresholds when a new feature gets unlocked
public static userJourney = {
diff --git a/UI/Reviews/ReviewForm.ts b/UI/Reviews/ReviewForm.ts
index 417d44ef5..4f15a1d4c 100644
--- a/UI/Reviews/ReviewForm.ts
+++ b/UI/Reviews/ReviewForm.ts
@@ -27,6 +27,7 @@ export default class ReviewForm extends InputElement {
this.userDetails = userDetails;
const t = Translations.t.reviews;
this._value = new UIEventSource({
+ made_by_user: false,
rating: undefined,
comment: undefined,
author: userDetails.data.name,
@@ -53,7 +54,7 @@ export default class ReviewForm extends InputElement {
.onClick(() => {
self._saveButton = Translations.t.reviews.saving_review;
onSave(this._value.data, () => {
- self._saveButton = Translations.t.reviews.saved;
+ self._saveButton = Translations.t.reviews.saved.SetClass("thanks");
});
})
@@ -97,7 +98,9 @@ export default class ReviewForm extends InputElement {
new Combine([
this._isAffiliated,
this._saveButton
- ]).SetClass("review-form-bottom")
+ ]).SetClass("review-form-bottom"),
+ "
",
+ Translations.t.reviews.tos.SetClass("subtle")
])
.SetClass("review-form")
.Render();
diff --git a/UI/SpecialVisualizations.ts b/UI/SpecialVisualizations.ts
index 1b45a32b9..2da5fbb2e 100644
--- a/UI/SpecialVisualizations.ts
+++ b/UI/SpecialVisualizations.ts
@@ -168,7 +168,7 @@ export default class SpecialVisualizations {
State.state.mangroveIdentity,
State.state.osmConnection._dryRun
);
- const form = new ReviewForm(r => mangrove.AddReview(r), State.state.osmConnection.userDetails);
+ const form = new ReviewForm((r, whenDone) => mangrove.AddReview(r, whenDone), State.state.osmConnection.userDetails);
return new ReviewElement(mangrove.GetSubjectUri(), mangrove.GetReviews(), form);
}
},
diff --git a/assets/translations.json b/assets/translations.json
index a660e54e5..fc6ee3881 100644
--- a/assets/translations.json
+++ b/assets/translations.json
@@ -953,9 +953,13 @@
"en": "Review saved. Thanks for sharing!",
"nl": "Bedankt om je beoordeling te delen!"
},
+ "tos": {
+ "en": "If you create a review, you agree to the TOS and privacy policy of Mangrove.reviews",
+ "nl": "Als je je review publiceert, ga je akkoord met de de gebruiksvoorwaarden en privacy policy van Mangrove.reviews"
+ },
"attribution": {
- "en": "Reviews are powered by Mangrove Reviews and are available under CC-BY 4.0",
- "nl": "De beoordelingen worden voorzien door Mangrove Reviews en zijn beschikbaar onder deCC-BY 4.0-licentie "
+ "en": "Reviews are powered by Mangrove Reviews and are available under CC-BY 4.0.",
+ "nl": "De beoordelingen worden voorzien door Mangrove Reviews en zijn beschikbaar onder deCC-BY 4.0-licentie. "
},
"plz_login": {
"en": "Login to leave a review",
diff --git a/package-lock.json b/package-lock.json
index 59b505924..139932c6b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -6805,11 +6805,6 @@
}
}
},
- "jose": {
- "version": "3.3.1",
- "resolved": "https://registry.npmjs.org/jose/-/jose-3.3.1.tgz",
- "integrity": "sha512-dMVfVKnyJyl2d9OBkwu/nvheGh9fbS1khhkJdvbGnINNe8IUfSJ/U+BXJOQvk65BCIJ58lp7xQKJTGQQ5dxrZA=="
- },
"jquery": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz",