@@ -49,7 +71,8 @@
import Socket from "./Socket.vue";
import contenteditable from 'vue-contenteditable';
import {config} from "../api";
-import {SiteConstructorParams} from "../result";
+import {default_links, SiteConstructorParams} from "../result";
+import {link_types, link_icons} from "../result";
export default {
name: "SiteSettings",
@@ -83,7 +106,7 @@ export default {
}
},
watch: {
- site_rec_patched () {
+ site_rec_patched() {
this.$emit('change', this.site_rec_patched);
},
constructor_params: {
@@ -107,12 +130,22 @@ export default {
} else {
return this.site_rec;
}
+ },
+ link_types() {
+ // return the types from link_types that are not in the constructor_params.contacts
+ return link_types.filter(link_type => !(link_type in this.constructor_params.contacts));
+ },
+ link_icons() {
+ return link_icons;
}
},
methods: {
set_site_rec(site_rec) {
this.site_rec = site_rec;
},
+ addLink(link_type) {
+ this.constructor_params.contacts[link_type] = default_links[link_type];
+ },
}
}
@@ -191,4 +224,21 @@ export default {
.site-record-field {
font-family: 'Inconsolata', monospace;
}
+
+.link-type:not(:last-child) {
+ margin-right: 1rem;
+}
+
+.link-type-icon.add {
+ font-size: 2rem;
+ cursor: pointer;
+}
+
+.link-type-icon.add:hover {
+ color: #e88484;
+}
+
+.link-type-icon {
+ font-size: 2.5rem;
+}
\ No newline at end of file
diff --git a/src/main.ts b/src/main.ts
index f276049..a82a311 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -87,6 +87,9 @@ const store = createStore({
}
}
return null;
+ },
+ async disconnect({state}) {
+ await state.connector.disconnect();
}
}
})
diff --git a/src/result.ts b/src/result.ts
index bf20b1f..91927d6 100644
--- a/src/result.ts
+++ b/src/result.ts
@@ -144,12 +144,21 @@ export function get_ton_link(res: Result) {
return new TonLink(res.zone(), 'b/' + res.domain, res.buy_price!);
}
+export let link_types = ['telegram', 'website', 'getgems', 'email'];
+export let link_icons = {'telegram': 'fab fa-telegram', 'website': 'material-icons language', 'getgems': 'fas fa-gem', 'email': 'fas fa-envelope'};
+export let default_links = {'telegram': 'https://t.me/', 'website': 'https://', 'getgems': 'https://getgems.org/', 'email': 'example@example.org'};
+
export class SiteConstructorParams {
domain: string;
title: string;
- constructor(domain: string, title: string = '') {
+ description: string;
+ contacts: Map = new Map();
+
+ constructor(domain: string, title: string = '', description: string = '', contacts: Map = new Map()) {
this.domain = domain;
this.title = title;
+ this.description = description;
+ this.contacts = contacts;
}
copy(): SiteConstructorParams {
@@ -159,5 +168,5 @@ export class SiteConstructorParams {
export async function get_constr_params(domain: string) {
let res = await call_api('get-site-data/' + domain);
- return new SiteConstructorParams(res.domain, res.title);
+ return new SiteConstructorParams(res.domain, res.title, res.description, res.contacts);
}
diff --git a/src/views/Explore.vue b/src/views/Explore.vue
index 9bba45f..b8d753c 100644
--- a/src/views/Explore.vue
+++ b/src/views/Explore.vue
@@ -90,11 +90,11 @@ export default {
signingWallet: false,
constructor_params: saved_constructor_params,
saved_constructor_params,
- timer: ''
+ interval: null
}
},
mounted() {
- setInterval(() => get_domain_result(this.domain, this.$store.getters.address).then(r => {
+ this.interval = setInterval(() => get_domain_result(this.domain, this.$store.getters.address).then(r => {
this.result = Object.assign({}, r);
if (this.isMine) {
get_constr_params(this.domain).then(r => {
@@ -108,7 +108,7 @@ export default {
this.updSettingsComponent()
})
}
- }), 10000);
+ }), 20000);
},
computed: {
core_domain() {
@@ -137,7 +137,7 @@ export default {
siteChanged() {
let constr_change = false;
if (this.site_rec === config.agorata_adnl) {
- constr_change = this.constructor_params.title !== this.saved_constructor_params.title;
+ constr_change = this.constructor_params !== this.saved_constructor_params;
}
return this.records && (this.site_rec !== this.records.site || constr_change);
},
@@ -242,6 +242,9 @@ export default {
this.updSettingsComponent();
}
}
+ },
+ unmounted() {
+ clearInterval(this.interval);
}
}