diff --git a/package-lock.json b/package-lock.json index 0d44bb14..053b962b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13760,8 +13760,7 @@ "vue": { "version": "2.6.11", "resolved": "https://registry.npmjs.org/vue/-/vue-2.6.11.tgz", - "integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==", - "dev": true + "integrity": "sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==" }, "vue-agile": { "version": "1.1.3", @@ -14042,6 +14041,11 @@ "smoothscroll-polyfill": "^0.4.3" } }, + "vuex": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.5.1.tgz", + "integrity": "sha512-w7oJzmHQs0FM9LXodfskhw9wgKBiaB+totOdb8sNzbTB2KDCEEwEs29NzBZFh/lmEK1t5tDmM1vtsO7ubG1DFw==" + }, "watchpack": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.2.tgz", diff --git a/package.json b/package.json index 177cb85f..ccad9c33 100644 --- a/package.json +++ b/package.json @@ -39,10 +39,12 @@ "marked": "^1.1.1", "material-design-icons": "^3.0.1", "sweetalert2": "^9.17.1", + "vue": "^2.6.11", "vue-agile": "^1.1.3", "vue-material-design-icons": "^4.8.0", "vue-moment": "^4.1.0", "vue-sweetalert2": "^3.0.6", - "vuepress-plugin-sitemap": "^2.3.1" + "vuepress-plugin-sitemap": "^2.3.1", + "vuex": "^3.5.1" } } diff --git a/src/.vuepress/components/DownloadButtons.vue b/src/.vuepress/components/DownloadButtons.vue index ef45478e..4eff1544 100644 --- a/src/.vuepress/components/DownloadButtons.vue +++ b/src/.vuepress/components/DownloadButtons.vue @@ -1,143 +1,146 @@ - - - - - Stable - - - Preview - - - Requires Android 5.0 or higher. - - - - - - + + + + + Stable + + + Preview + + + Requires Android 5.0 or higher. + + + + + + diff --git a/src/.vuepress/components/ReleaseDate.vue b/src/.vuepress/components/ReleaseDate.vue index 22704861..b963b8a7 100644 --- a/src/.vuepress/components/ReleaseDate.vue +++ b/src/.vuepress/components/ReleaseDate.vue @@ -5,9 +5,6 @@ diff --git a/src/.vuepress/components/VersionTag.vue b/src/.vuepress/components/VersionTag.vue index 5a1d287a..54a10598 100644 --- a/src/.vuepress/components/VersionTag.vue +++ b/src/.vuepress/components/VersionTag.vue @@ -8,9 +8,6 @@ diff --git a/src/.vuepress/components/WhatsNew.vue b/src/.vuepress/components/WhatsNew.vue index c3a5cdcf..f085795c 100644 --- a/src/.vuepress/components/WhatsNew.vue +++ b/src/.vuepress/components/WhatsNew.vue @@ -12,9 +12,7 @@ diff --git a/src/.vuepress/enhanceApp.js b/src/.vuepress/enhanceApp.js index 23ece59a..76419e66 100644 --- a/src/.vuepress/enhanceApp.js +++ b/src/.vuepress/enhanceApp.js @@ -7,6 +7,8 @@ import { VueAgile } from "vue-agile"; import VueSweetalert2 from "vue-sweetalert2"; import VueMoment from "vue-moment"; +import store from "./store"; + export default ({ Vue, // the version of Vue being used in the VuePress app options, // the options for the root Vue instance @@ -17,4 +19,5 @@ export default ({ Vue.component("Agile", VueAgile); Vue.use(VueSweetalert2); Vue.use(VueMoment); + Vue.mixin({ store }); }; diff --git a/src/.vuepress/store/index.js b/src/.vuepress/store/index.js new file mode 100644 index 00000000..bbe45305 --- /dev/null +++ b/src/.vuepress/store/index.js @@ -0,0 +1,63 @@ +import Vue from "vue"; +import Vuex from "vuex"; +import axios from "axios"; + +import { GITHUB_LATEST_API } from "../constants"; + +let call = null; + +Vue.use(Vuex); +export default new Vuex.Store({ + state: { + stable: { + updated: null, + data: null, + }, + }, + mutations: { + setStableReleaseData(state, stable) { + // eslint-disable-next-line no-param-reassign + state.stable = stable; + }, + }, + actions: { + getStableReleaseData({ commit }) { + return new Promise((resolve, reject) => { + const { updated } = this.state.stable; + const now = new Date().getTime(); + + if (updated != null && now - updated <= 60 * 60 * 24 * 1000) { + return resolve(this.state.stable); + } + + // Makes sure only one network call and one mutation happens + if (call == null) { + call = axios.get(GITHUB_LATEST_API).then(({ data }) => { + const object = { + updated: now, + data, + }; + commit("setStableReleaseData", object); + call = null; + return Promise.resolve(this.state.stable) + }).catch((reason) => { + const object = { + updated: null, + data: null, + }; + commit("setStableReleaseData", object); + call = null + return Promise.reject(reason) + });; + } + + // Waits for network call and mutation to be done + return call.then((value) => { + return resolve(value); + }).catch((reason) => { + return reject(reason); + }); + }); + }, + }, +}); \ No newline at end of file diff --git a/src/.vuepress/theme/components/Home.vue b/src/.vuepress/theme/components/Home.vue index 0b24cae3..743537d2 100644 --- a/src/.vuepress/theme/components/Home.vue +++ b/src/.vuepress/theme/components/Home.vue @@ -60,10 +60,8 @@