diff --git a/package.json b/package.json index c3bacec95..459c92c35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hyphadac-quasar", - "version": "1.0.27", + "version": "1.0.28", "description": "HyphaDAO", "productName": "HyphaDAO", "cordovaId": "org.cordova.quasar.app", diff --git a/src/pages/proposals/components/draft-proposal-card.vue b/src/pages/proposals/components/draft-proposal-card.vue index 462bbb448..7b2ad2b44 100644 --- a/src/pages/proposals/components/draft-proposal-card.vue +++ b/src/pages/proposals/components/draft-proposal-card.vue @@ -134,9 +134,25 @@ q-card.draft q-item-section Edit q-item( clickable - v-close-popup - @click="deleteDraft(draft.id)" ) + q-popup-proxy + .confirm.column.q-pa-sm + | Are you sure you want to delete this draft? + .row.flex.justify-between.q-mt-sm + q-btn( + color="primary" + label="No" + dense + flat + v-close-popup="-1" + ) + q-btn( + color="primary" + label="Yes" + dense + @click="deleteDraft(draft.id)" + v-close-popup="-1" + ) q-item-section(style="max-width: 20px;") q-icon(name="fas fa-trash-alt" size="14px") q-item-section Delete diff --git a/src/pages/proposals/components/proposal-card.vue b/src/pages/proposals/components/proposal-card.vue index 2efdd694c..975223d03 100644 --- a/src/pages/proposals/components/proposal-card.vue +++ b/src/pages/proposals/components/proposal-card.vue @@ -225,7 +225,7 @@ q-card.proposal(v-if="isFiltered") img.icon(v-if="origin === 'assignment' || type === 'assignment'" src="~assets/icons/assignments.svg") img.icon(v-if="origin === 'contribution' || type === 'contribution'" src="~assets/icons/past.svg") q-card-section - .type(@click="showCardFullContent") {{ type }} #[br] {{ origin }} + .type(@click="showCardFullContent") {{ type }} {{ origin }} .title(@click="details = !details") {{ title }} q-card-section.description(v-show="details") p {{ description | truncate(150) }} diff --git a/src/store/profiles/actions.js b/src/store/profiles/actions.js index d50a32417..2f5fda86f 100644 --- a/src/store/profiles/actions.js +++ b/src/store/profiles/actions.js @@ -1,5 +1,4 @@ import Turndown from 'turndown' -import { Notify } from 'quasar' export const connectProfileApi = async function ({ commit }) { await this.$ppp.authApi().signIn() @@ -45,21 +44,8 @@ export const getPublicProfile = async function ({ commit, state, rootGetters }, return profile } -export const getDrafts = async function ({ commit, state }, username) { - if (state.loadings[username]) { - while (!state.profiles[username]) { - await sleep(200) - } - } - if (state.profiles[username]) { - commit('setDrafts', state.profiles[username].publicData.drafts || []) - } else { - commit('setLoading', username) - const profile = (await this.$ppp.profileApi().getProfiles([username]))[username] - if (!profile) return null - commit('addProfile', { profile, username }) - commit('setDrafts', profile.publicData.drafts || []) - } +export const getDrafts = async function ({ commit }) { + commit('setDrafts', JSON.parse(localStorage.getItem('drafts') || [])) } export const getTokensAmounts = async function (context, account) { @@ -279,48 +265,20 @@ export const deleteDraft = async function ({ commit, state, dispatch }, id) { } export const saveDraft = async function ({ commit, state, dispatch }, data) { - try { - if (!state.connected) { - await dispatch('connectProfileApi') - } - const drafts = [...state.drafts] - // replace an existing draft - if (data) { - const { type, draft } = data - const idx = drafts.findIndex(d => d.draft.id === draft.id && d.type === type) - if (idx >= 0) { - drafts[idx] = { type, draft } - } else { - drafts.push({ type, draft }) - } - } - - const profile = await this.$ppp.profileApi().getProfile('BASE_AND_APP') - if (!profile) { - Notify.create({ - color: 'red', - message: 'Please create profile before submitting a proposal.', - position: 'bottom', - timeout: 10000, - actions: [ - { label: 'Dismiss', color: 'white', handler: () => { /* ... */ } } - ] - }) - return false + const drafts = [...state.drafts] + // replace an existing draft + if (data) { + const { type, draft } = data + const idx = drafts.findIndex(d => d.draft.id === draft.id && d.type === type) + if (idx >= 0) { + drafts[idx] = { type, draft } + } else { + drafts.push({ type, draft }) } - await this.$ppp.profileApi().register({ - ...profile, - publicData: { - ...profile.publicData, - drafts - } - }) - commit('setDrafts', drafts) - return true - } catch (e) { - this.$sentry.captureException(e) - return false } + localStorage.setItem('drafts', JSON.stringify(drafts)) + commit('setDrafts', drafts) + return true } const sleep = (ms) => {