+
@@ -125,4 +130,11 @@
.status-el:last-child .status {
border: none
}
+
+ .icon-cancel,.delete-status {
+ cursor: pointer;
+ &:hover {
+ color: $red;
+ }
+ }
diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue
index fef96e4e..7de3ffca 100644
--- a/src/components/timeline/timeline.vue
+++ b/src/components/timeline/timeline.vue
@@ -18,10 +18,3 @@
-
-
diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue
index 767982c5..eaa5396d 100644
--- a/src/components/user_profile/user_profile.vue
+++ b/src/components/user_profile/user_profile.vue
@@ -5,10 +5,3 @@
-
-
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index f4bffebf..aab198d8 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -54,6 +54,9 @@ export const prepareStatus = (status) => {
status.nsfw = !!status.text.match(nsfwRegex)
}
+ // Set deleted flag
+ status.deleted = false
+
// To make the array reactive
status.attachments = status.attachments || []
@@ -261,6 +264,10 @@ export const mutations = {
const newStatus = find(state.allStatuses, status)
newStatus.repeated = value
},
+ setDeleted (state, { status }) {
+ const newStatus = find(state.allStatuses, status)
+ newStatus.deleted = true
+ },
setLoading (state, { timeline, value }) {
state.timelines[timeline].loading = value
},
@@ -276,6 +283,10 @@ const statuses = {
addNewStatuses ({ rootState, commit }, { statuses, showImmediately = false, timeline = false, noIdUpdate = false }) {
commit('addNewStatuses', { statuses, showImmediately, timeline, noIdUpdate, user: rootState.users.currentUser })
},
+ deleteStatus ({ rootState, commit }, status) {
+ commit('setDeleted', { status })
+ apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
+ },
favorite ({ rootState, commit }, status) {
// Optimistic favoriting...
commit('setFavorited', { status, value: true })
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 47895d3b..a78ab5c9 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -7,6 +7,7 @@ const FAVORITE_URL = '/api/favorites/create'
const UNFAVORITE_URL = '/api/favorites/destroy'
const RETWEET_URL = '/api/statuses/retweet'
const STATUS_UPDATE_URL = '/api/statuses/update.json'
+const STATUS_DELETE_URL = '/api/statuses/destroy'
const STATUS_URL = '/api/statuses/show'
const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload'
const CONVERSATION_URL = '/api/statusnet/conversation'
@@ -118,6 +119,13 @@ const postStatus = ({credentials, status, mediaIds, inReplyToStatusId}) => {
})
}
+const deleteStatus = ({ id, credentials }) => {
+ return fetch(`${STATUS_DELETE_URL}/${id}.json`, {
+ headers: authHeaders(credentials),
+ method: 'POST'
+ })
+}
+
const uploadMedia = ({formData, credentials}) => {
return fetch(MEDIA_UPLOAD_URL, {
body: formData,
@@ -139,6 +147,7 @@ const apiService = {
unfavorite,
retweet,
postStatus,
+ deleteStatus,
uploadMedia
}
diff --git a/test/unit/specs/modules/statuses.spec.js b/test/unit/specs/modules/statuses.spec.js
index deeeb477..6c048372 100644
--- a/test/unit/specs/modules/statuses.spec.js
+++ b/test/unit/specs/modules/statuses.spec.js
@@ -44,6 +44,11 @@ describe('Statuses.prepareStatus', () => {
expect(prepareStatus(nsfw).nsfw).to.eq(false)
})
+
+ it('sets deleted flag to false', () => {
+ const aStatus = makeMockStatus({id: 1, text: 'Hello oniichan'})
+ expect(prepareStatus(aStatus).deleted).to.eq(false)
+ })
})
describe('Statuses.findMaxId', () => {