From 15800bab576b1a1e1ef5eab61b6d0d16ea6dfd5e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 6 Nov 2016 17:43:31 +0100 Subject: Add mp4 to attachments. --- src/components/attachment/attachment.js | 4 ++-- src/components/attachment/attachment.vue | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/components') diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 161c6b2b..85d924d0 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -19,8 +19,8 @@ const Attachment = { type = 'image'; } - if(this.attachment.mimetype.match(/video\/webm/)) { - type = 'webm'; + if(this.attachment.mimetype.match(/video\/(webm|mp4)/)) { + type = 'video'; }; return type diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 7feab42c..09ca5fa9 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -6,7 +6,7 @@ - + Don't know how to display this... -- cgit v1.2.3-70-g09d2 From e1103f04a44133fa5775b0be1fd5e2acce79daef Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 6 Nov 2016 17:44:05 +0100 Subject: Add fetching of older statuses. --- src/components/timeline/timeline.js | 13 +++++++++++++ src/components/timeline/timeline.vue | 7 +++++++ src/modules/statuses.js | 17 ++++++++++++----- .../timeline_fetcher/timeline_fetcher.service.js | 6 ++++-- 4 files changed, 36 insertions(+), 7 deletions(-) (limited to 'src/components') diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 433bca11..113455f4 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -1,4 +1,5 @@ import Status from '../status/status.vue' +import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.service.js' const Timeline = { props: [ @@ -11,6 +12,18 @@ const Timeline = { methods: { showNewStatuses () { this.$store.commit('showNewStatuses', { timeline: this.timelineName }) + }, + fetchOlderStatuses () { + const store = this.$store + const credentials = store.state.users.currentUser.credentials + store.commit('setLoading', { timeline: this.timelineName, value: true }); + timelineFetcher.fetchAndUpdate({ + store, + credentials, + timeline: this.timelineName, + older: true, + showImmediately: true + }).then(() => store.commit('setLoading', { timeline: this.timelineName, value: false })) } } } diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index 1e779638..2f1b8c28 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -8,6 +8,13 @@ + +
+

+ Load older statuses. +

+
+
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index c3692ae7..5fb57a4f 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -12,7 +12,8 @@ const defaultState = { visibleStatuses: [], newStatusCount: 0, maxId: 0, - minVisibleId: 0 + minVisibleId: 0, + loading: false }, publicAndExternal: { statuses: [], @@ -20,7 +21,8 @@ const defaultState = { visibleStatuses: [], newStatusCount: 0, maxId: 0, - minVisibleId: 0 + minVisibleId: 0, + loading: false }, friends: { statuses: [], @@ -28,7 +30,8 @@ const defaultState = { visibleStatuses: [], newStatusCount: 0, maxId: 0, - minVisibleId: 0 + minVisibleId: 0, + loading: false } } } @@ -37,7 +40,7 @@ const statusType = (status) => { return !status.is_post_verb && status.uri.match(/fave/) ? 'fave' : 'status' } -const addStatusesToTimeline = (addedStatuses, showImmediately, { statuses, visibleStatuses, newStatusCount, faves }) => { +const addStatusesToTimeline = (addedStatuses, showImmediately, { statuses, visibleStatuses, newStatusCount, faves, loading }) => { const statusesAndFaves = groupBy(addedStatuses, statusType) const addedFaves = statusesAndFaves['fave'] || [] const unseenFaves = differenceBy(addedFaves, faves, 'id') @@ -92,7 +95,8 @@ const addStatusesToTimeline = (addedStatuses, showImmediately, { statuses, visib newStatusCount: newNewStatusCount, maxId: newStatuses[0].id, minVisibleId: (last(newVisibleStatuses) || { id: undefined }).id, - faves: unionBy(faves, addedFaves, 'id') + faves: unionBy(faves, addedFaves, 'id'), + loading } } @@ -138,6 +142,9 @@ const statuses = { const newStatus = find(state.allStatuses, status) newStatus.favorited = value }, + setLoading (state, { timeline, value }) { + state.timelines[timeline].loading = value + }, setNsfw (state, { id, nsfw }) { // For now, walk through all the statuses because the stuff might be in the replied_to_status // TODO: Save the replied_tos as references. diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index a3d9b9d1..8a39eeb5 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -16,7 +16,8 @@ const update = ({store, statuses, timeline, showImmediately}) => { const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false, showImmediately = false}) => { const args = { timeline, credentials } - const timelineData = store.rootState.statuses.timelines[camelCase(timeline)] + const rootState = store.rootState || store.state + const timelineData = rootState.statuses.timelines[camelCase(timeline)] if (older) { args['until'] = timelineData.minVisibleId @@ -24,7 +25,7 @@ const fetchAndUpdate = ({store, credentials, timeline = 'friends', older = false args['since'] = timelineData.maxId } - apiService.fetchTimeline(args) + return apiService.fetchTimeline(args) .then((statuses) => update({store, statuses, timeline, showImmediately})) } @@ -35,6 +36,7 @@ const startFetching = ({ timeline = 'friends', credentials, store }) => { setInterval(boundFetchAndUpdate, 10000) } const timelineFetcher = { + fetchAndUpdate, startFetching } -- cgit v1.2.3-70-g09d2 From a73916dd7f07954ee0305df822baa8068ae1df14 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 6 Nov 2016 19:28:37 +0100 Subject: Add MediaUpload component. --- src/components/media_upload/media_upload.js | 22 ++++++++++++++++++++++ src/components/media_upload/media_upload.vue | 17 +++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/components/media_upload/media_upload.js create mode 100644 src/components/media_upload/media_upload.vue (limited to 'src/components') diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js new file mode 100644 index 00000000..c24c71e9 --- /dev/null +++ b/src/components/media_upload/media_upload.js @@ -0,0 +1,22 @@ +/* eslint-env browser */ +import statusPosterService from '../../services/status_poster/status_poster.service.js' + +const mediaUpload = { + mounted () { + const store = this.$store + const input = this.$el.querySelector('input') + const self = this + + input.addEventListener('change', ({target}) => { + const file = target.files[0]; + const formData = new FormData(); + formData.append('media', file); + statusPosterService.uploadMedia({ store, formData }) + .then((fileData) => { + self.$emit('uploaded', fileData) + }) + }) + } +} + +export default mediaUpload diff --git a/src/components/media_upload/media_upload.vue b/src/components/media_upload/media_upload.vue new file mode 100644 index 00000000..a62d8316 --- /dev/null +++ b/src/components/media_upload/media_upload.vue @@ -0,0 +1,17 @@ + + + + + -- cgit v1.2.3-70-g09d2 From e21a60096c397f949848db0de4699eb41a7623de Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 6 Nov 2016 19:30:35 +0100 Subject: Add media upload to PostStatusForm. --- src/components/post_status_form/post_status_form.js | 17 +++++++++++++++-- src/components/post_status_form/post_status_form.vue | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/components') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 2c015154..30a7cd40 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -1,4 +1,6 @@ import statusPoster from '../../services/status_poster/status_poster.service.js' +import MediaUpload from '../media_upload/media_upload.vue' + import { reject, map, uniqBy } from 'lodash'; const buildMentionsString = ({user, attentions}, currentUser) => { @@ -23,6 +25,9 @@ const PostStatusForm = { 'repliedUser', 'attentions' ], + components: { + MediaUpload + }, data () { let statusText = '' @@ -33,7 +38,8 @@ const PostStatusForm = { return { newStatus: { - status: statusText + status: statusText, + files: [] } } }, @@ -41,11 +47,18 @@ const PostStatusForm = { postStatus (newStatus) { statusPoster.postStatus({ status: newStatus.status, + media: newStatus.files, store: this.$store, inReplyToStatusId: this.replyTo }) - this.newStatus = { } + this.newStatus = { + status: '', + files: [] + } this.$emit('posted') + }, + addMediaFile (fileInfo) { + this.newStatus.files.push(fileInfo) } } } diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index d2106d5a..943bf422 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -10,7 +10,7 @@
- +
-- cgit v1.2.3-70-g09d2 From 521c81525147798e7de93f90c7fe1b312564fbe6 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 6 Nov 2016 20:10:20 +0100 Subject: Add NavPanel. --- src/components/nav_panel/nav_panel.js | 4 +++ src/components/nav_panel/nav_panel.vue | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/components/nav_panel/nav_panel.js create mode 100644 src/components/nav_panel/nav_panel.vue (limited to 'src/components') diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js new file mode 100644 index 00000000..318d30cc --- /dev/null +++ b/src/components/nav_panel/nav_panel.js @@ -0,0 +1,4 @@ +const NavPanel = { +} + +export default NavPanel diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue new file mode 100644 index 00000000..b535b092 --- /dev/null +++ b/src/components/nav_panel/nav_panel.vue @@ -0,0 +1,54 @@ + + + + + -- cgit v1.2.3-70-g09d2 From c9e235f8898c4f1c4c1c2d5111ad34b1dd4ffa10 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 6 Nov 2016 20:11:00 +0100 Subject: Load timeline once on creation. --- src/components/timeline/timeline.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/components') diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 113455f4..e0c75d76 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -9,6 +9,17 @@ const Timeline = { components: { Status }, + created () { + const store = this.$store + const credentials = store.state.users.currentUser.credentials + + timelineFetcher.fetchAndUpdate({ + store, + credentials, + timeline: this.timelineName, + showImmediately: true + }) + }, methods: { showNewStatuses () { this.$store.commit('showNewStatuses', { timeline: this.timelineName }) -- cgit v1.2.3-70-g09d2 From 7fcd36e2c19c29ce36086a85e59cc297d3474841 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 6 Nov 2016 20:45:26 +0100 Subject: Don't show actions when not logged in. --- src/components/status/status.js | 3 +++ src/components/status/status.vue | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/status/status.js b/src/components/status/status.js index 2e6565e8..6253d334 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -16,6 +16,9 @@ const Status = { } else { return this.statusoid } + }, + loggedIn () { + return !!this.$store.state.users.currentUser } }, components: { diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 8361aa52..1c5dc458 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -32,7 +32,7 @@ -
+
diff --git a/src/components/public_and_external_timeline/public_and_external_timeline.js b/src/components/public_and_external_timeline/public_and_external_timeline.js new file mode 100644 index 00000000..138118ad --- /dev/null +++ b/src/components/public_and_external_timeline/public_and_external_timeline.js @@ -0,0 +1,11 @@ +import Timeline from '../timeline/timeline.vue' +const PublicAndExternalTimeline = { + components: { + Timeline + }, + computed: { + timeline () { return this.$store.state.statuses.timelines.publicAndExternal } + } +} + +export default PublicAndExternalTimeline diff --git a/src/components/public_and_external_timeline/public_and_external_timeline.vue b/src/components/public_and_external_timeline/public_and_external_timeline.vue new file mode 100644 index 00000000..94cdaf17 --- /dev/null +++ b/src/components/public_and_external_timeline/public_and_external_timeline.vue @@ -0,0 +1,10 @@ + + + diff --git a/src/main.js b/src/main.js index 7f917128..de3b2af1 100644 --- a/src/main.js +++ b/src/main.js @@ -3,6 +3,7 @@ import VueRouter from 'vue-router' import Vuex from 'vuex' import App from './App.vue' import PublicTimeline from './components/public_timeline/public_timeline.vue' +import PublicAndExternalTimeline from './components/public_and_external_timeline/public_and_external_timeline.vue' import FriendsTimeline from './components/friends_timeline/friends_timeline.vue' import statusesModule from './modules/statuses.js' @@ -19,7 +20,8 @@ const store = new Vuex.Store({ }) const routes = [ - { path: '/', redirect: '/main/public' }, + { path: '/', redirect: '/main/all' }, + { path: '/main/all', component: PublicAndExternalTimeline }, { path: '/main/public', component: PublicTimeline }, { path: '/main/friends', component: FriendsTimeline } ] diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 9538517d..06585ac7 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -26,7 +26,7 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false}) => const timelineUrls = { public: PUBLIC_TIMELINE_URL, friends: FRIENDS_TIMELINE_URL, - 'public-and-external': PUBLIC_AND_EXTERNAL_TIMELINE_URL + 'publicAndExternal': PUBLIC_AND_EXTERNAL_TIMELINE_URL } let url = timelineUrls[timeline] -- cgit v1.2.3-70-g09d2