From f6b2f6eaeed78ba4e4a6d12189b7d96474e54915 Mon Sep 17 00:00:00 2001 From: shpuld Date: Mon, 20 Nov 2017 22:45:09 +0200 Subject: [PATCH 01/29] Fix usercard from breaking with certain colors, clean up code structure a bit. --- .../style_switcher/style_switcher.js | 9 +-- .../user_card_content/user_card_content.js | 64 +++++++++++++++++++ .../user_card_content/user_card_content.vue | 64 +------------------ src/services/color_convert/color_convert.js | 34 ++++++++++ src/services/style_setter/style_setter.js | 22 +------ 5 files changed, 103 insertions(+), 90 deletions(-) create mode 100644 src/components/user_card_content/user_card_content.js create mode 100644 src/services/color_convert/color_convert.js diff --git a/src/components/style_switcher/style_switcher.js b/src/components/style_switcher/style_switcher.js index b1359d13..a762f914 100644 --- a/src/components/style_switcher/style_switcher.js +++ b/src/components/style_switcher/style_switcher.js @@ -1,3 +1,5 @@ +import { rgbstr2hex } from '../../services/color_convert/color_convert.js' + export default { data () { return { @@ -19,13 +21,6 @@ export default { }) }, mounted () { - const rgbstr2hex = (rgb) => { - if (rgb[0] === '#') { - return rgb - } - rgb = rgb.match(/\d+/g) - return `#${((Number(rgb[0]) << 16) + (Number(rgb[1]) << 8) + Number(rgb[2])).toString(16)}` - } this.bgColorLocal = rgbstr2hex(this.$store.state.config.colors['base00']) this.fgColorLocal = rgbstr2hex(this.$store.state.config.colors['base02']) this.textColorLocal = rgbstr2hex(this.$store.state.config.colors['base05']) diff --git a/src/components/user_card_content/user_card_content.js b/src/components/user_card_content/user_card_content.js new file mode 100644 index 00000000..6e67a321 --- /dev/null +++ b/src/components/user_card_content/user_card_content.js @@ -0,0 +1,64 @@ +import { hex2rgb } from '../../services/color_convert/color_convert.js' + +export default { + props: [ 'user', 'switcher' ], + computed: { + headingStyle () { + const color = this.$store.state.config.colors['base00'] + if (color) { + const rgb = hex2rgb(color) + console.log(rgb) + return { + backgroundColor: `rgb(${Math.floor(rgb[0] * 0.53)}, ${Math.floor(rgb[1] * 0.56)}, ${Math.floor(rgb[2] * 0.59)})`, + backgroundImage: `url(${this.user.cover_photo})` + } + } + }, + bodyStyle () { + return { + background: `linear-gradient(to bottom, rgba(0, 0, 0, 0), ${this.$store.state.config.colors['base00']} 80%)` + } + }, + isOtherUser () { + return this.user.id !== this.$store.state.users.currentUser.id + }, + loggedIn () { + return this.$store.state.users.currentUser + }, + dailyAvg () { + const days = Math.ceil((new Date() - new Date(this.user.created_at)) / (60 * 60 * 24 * 1000)) + return Math.round(this.user.statuses_count / days) + } + }, + methods: { + followUser () { + const store = this.$store + store.state.api.backendInteractor.followUser(this.user.id) + .then((followedUser) => store.commit('addNewUsers', [followedUser])) + }, + unfollowUser () { + const store = this.$store + store.state.api.backendInteractor.unfollowUser(this.user.id) + .then((unfollowedUser) => store.commit('addNewUsers', [unfollowedUser])) + }, + blockUser () { + const store = this.$store + store.state.api.backendInteractor.blockUser(this.user.id) + .then((blockedUser) => store.commit('addNewUsers', [blockedUser])) + }, + unblockUser () { + const store = this.$store + store.state.api.backendInteractor.unblockUser(this.user.id) + .then((unblockedUser) => store.commit('addNewUsers', [unblockedUser])) + }, + toggleMute () { + const store = this.$store + store.commit('setMuted', {user: this.user, muted: !this.user.muted}) + store.state.api.backendInteractor.setUserMute(this.user) + }, + setProfileView (v) { + const store = this.$store + store.commit('setProfileView', { v }) + } + } +} diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue index 5635a177..d49a7d6c 100644 --- a/src/components/user_card_content/user_card_content.vue +++ b/src/components/user_card_content/user_card_content.vue @@ -84,69 +84,7 @@ - + diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue index d49a7d6c..4c40c55f 100644 --- a/src/components/user_card_content/user_card_content.vue +++ b/src/components/user_card_content/user_card_content.vue @@ -102,7 +102,6 @@ .profile-panel-body { top: -0em; padding-top: 4em; - word-wrap: break-word; } From 4e07b89bcfb821afb65d39eb389bcb0b4de697c8 Mon Sep 17 00:00:00 2001 From: shpuld Date: Tue, 21 Nov 2017 10:52:09 +0200 Subject: [PATCH 03/29] not so \!important after all --- src/components/attachment/attachment.vue | 7 +++++++ src/components/post_status_form/post_status_form.vue | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index 7a5923b4..57ff2625 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -34,6 +34,13 @@ display: flex; flex-wrap: wrap; margin-right: -0.7em; + + .attachment.media-upload-container { + flex: 0 0 auto; + max-height: 300px; + max-width: 100%; + } + .attachment { flex: 1 0 30%; margin: 0.5em 0.7em 0.6em 0.0em; diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index a0000654..19a00aeb 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -25,7 +25,7 @@
-
+
@@ -40,11 +40,6 @@ diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 55c89e6c..d6c8cdb3 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -324,7 +324,7 @@ color: $blue; } - .icon-reply-active { + .icon-reply.icon-reply-active { color: $blue; } From 326859464ca9fb2a7c9f2b4cc34f79e806776593 Mon Sep 17 00:00:00 2001 From: shpuld Date: Sat, 25 Nov 2017 00:09:28 +0200 Subject: [PATCH 11/29] Add the forgotten flex prop to make everything nice and tight again --- src/App.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/App.scss b/src/App.scss index 4146e68b..95a653ce 100644 --- a/src/App.scss +++ b/src/App.scss @@ -22,6 +22,7 @@ h4 { min-height: 100vh; max-width: 980px; background-color: rgba(0,0,0,0.15); + align-content: flex-start; } .text-center { From bcd10b34758b41cc09ec15153e9ca027fd4703f5 Mon Sep 17 00:00:00 2001 From: shpuld Date: Sat, 25 Nov 2017 12:57:55 +0200 Subject: [PATCH 12/29] Make star icon in notifications behave like the other icons.. --- src/components/notifications/notifications.scss | 4 ++++ src/components/notifications/notifications.vue | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss index db7b0843..241f10b4 100644 --- a/src/components/notifications/notifications.scss +++ b/src/components/notifications/notifications.scss @@ -59,6 +59,10 @@ color: $blue; } + .icon-star.lit { + color: orange; + } + .status-content { margin: 0; max-height: 300px; diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index 64624873..176695b1 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -17,7 +17,7 @@

{{ notification.action.user.name }} - +

From 1f413bb816699f871747dd88100e0cbd0a4550ce Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 28 Nov 2017 23:31:40 +0300 Subject: [PATCH 13/29] pasting images from clipboard, fuck ye --- src/components/post_status_form/post_status_form.js | 8 ++++++++ src/components/post_status_form/post_status_form.vue | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 6fc84407..acc97c86 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -153,6 +153,14 @@ const PostStatusForm = { type (fileInfo) { return fileTypeService.fileType(fileInfo.mimetype) }, + paste (e) { + if (e.clipboardData.files.length > 0) { + // Strangely, files property gets emptied after event propagation + // Trying to wrap it in array doesn't work. Plus I doubt it's possible + // to hold more than one file in clipboard. + this.dropFiles = [e.clipboardData.files[0]] + } + }, fileDrop (e) { if (e.dataTransfer.files.length > 0) { e.preventDefault() // allow dropping text like before diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 19a00aeb..bb2329f3 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -2,7 +2,7 @@
- +
From fbee80474baf3bfc41656268e22395983811f2f7 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 4 Dec 2017 19:08:33 +0100 Subject: [PATCH 14/29] Basic frontend changes for chat. --- config/index.js | 8 +++++++- package.json | 1 + src/components/nav_panel/nav_panel.vue | 5 +++++ src/i18n/messages.js | 4 ++++ src/main.js | 7 +++++-- src/modules/users.js | 14 +++++++++++++- yarn.lock | 4 ++++ 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/config/index.js b/config/index.js index 6652048c..c48d91b8 100644 --- a/config/index.js +++ b/config/index.js @@ -23,9 +23,15 @@ module.exports = { assetsPublicPath: '/', proxyTable: { '/api': { - target: 'https://social.heldscal.la/', + target: 'htts://localhost:4000/', changeOrigin: true, cookieDomainRewrite: 'localhost' + }, + '/socket': { + target: 'htts://localhost:4000/', + changeOrigin: true, + cookieDomainRewrite: 'localhost', + ws: true } }, // CSS Sourcemaps off by default because relative paths are "buggy" diff --git a/package.json b/package.json index e8d84274..4e98647b 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "localforage": "^1.5.0", "node-sass": "^3.10.1", "object-path": "^0.11.3", + "phoenix": "^1.3.0", "sanitize-html": "^1.13.0", "sass-loader": "^4.0.2", "vue": "^2.3.4", diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index aea841e9..fa4000b0 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -7,6 +7,11 @@ {{ $t("nav.timeline") }} +
  • + + {{ $t("nav.chat") }} + +
  • {{ $t("nav.mentions") }} diff --git a/src/i18n/messages.js b/src/i18n/messages.js index 9aeffdfa..ecb3557c 100644 --- a/src/i18n/messages.js +++ b/src/i18n/messages.js @@ -179,7 +179,11 @@ const fi = { } const en = { + chat: { + title: 'Chat' + }, nav: { + chat: 'Local Chat', timeline: 'Timeline', mentions: 'Mentions', public_tl: 'Public Timeline', diff --git a/src/main.js b/src/main.js index 6c5bf83e..ca3bb955 100644 --- a/src/main.js +++ b/src/main.js @@ -12,6 +12,7 @@ import UserProfile from './components/user_profile/user_profile.vue' import Settings from './components/settings/settings.vue' import Registration from './components/registration/registration.vue' import UserSettings from './components/user_settings/user_settings.vue' +import Chat from './components/chat/chat.vue' import statusesModule from './modules/statuses.js' import usersModule from './modules/users.js' @@ -60,7 +61,8 @@ const store = new Vuex.Store({ config: configModule }, plugins: [createPersistedState(persistedStateOptions)], - strict: process.env.NODE_ENV !== 'production' + strict: false // Socket modifies itself, let's ignore this for now. + // strict: process.env.NODE_ENV !== 'production' }) const i18n = new VueI18n({ @@ -90,7 +92,8 @@ window.fetch('/static/config.json') { name: 'mentions', path: '/:username/mentions', component: Mentions }, { name: 'settings', path: '/settings', component: Settings }, { name: 'registration', path: '/registration', component: Registration }, - { name: 'user-settings', path: '/user-settings', component: UserSettings } + { name: 'user-settings', path: '/user-settings', component: UserSettings }, + { name: 'chat', path: '/chat', component: Chat } ] const router = new VueRouter({ diff --git a/src/modules/users.js b/src/modules/users.js index 30f8dc27..a75271a4 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -1,6 +1,7 @@ import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import { compact, map, each, merge } from 'lodash' import { set } from 'vue' +import { Socket } from 'phoenix' // TODO: Unify with mergeOrAdd in statuses.js export const mergeOrAdd = (arr, obj, item) => { @@ -19,6 +20,9 @@ export const mergeOrAdd = (arr, obj, item) => { } export const mutations = { + setSocket (state, socket) { + state.socket = socket + }, setMuted (state, { user: {id}, muted }) { const user = state.usersObject[id] set(user, 'muted', muted) @@ -50,7 +54,8 @@ export const defaultState = { currentUser: false, loggingIn: false, users: [], - usersObject: {} + usersObject: {}, + socket: null } const users = { @@ -97,6 +102,13 @@ const users = { // Set our new backend interactor commit('setBackendInteractor', backendInteractorService(userCredentials)) + if (user.token) { + // Set up websocket connection + let socket = new Socket('/socket', {params: {token: user.token}}) + socket.connect() + store.commit('setSocket', socket) + } + // Start getting fresh tweets. store.dispatch('startFetching', 'friends') diff --git a/yarn.lock b/yarn.lock index d0d2dde9..3fcd29ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4226,6 +4226,10 @@ phantomjs-prebuilt@^2.1.3, phantomjs-prebuilt@^2.1.7: request-progress "~2.0.1" which "~1.2.10" +phoenix@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/phoenix/-/phoenix-1.3.0.tgz#1df2c27f986ee295e37c9983ec28ebac1d7f4a3e" + pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" From f4f63d32e2bc2622ebdfe7599cc8aca987ddcee4 Mon Sep 17 00:00:00 2001 From: eal Date: Mon, 4 Dec 2017 23:15:03 +0200 Subject: [PATCH 15/29] Fix basicauth base64 encoding for unicode passwords. --- src/services/api/api.service.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index fa95b870..5b078bc8 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -43,6 +43,16 @@ let fetch = (url, options) => { return oldfetch(fullUrl, options) } +// from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding +let utoa = (str) => { + // first we use encodeURIComponent to get percent-encoded UTF-8, + // then we convert the percent encodings into raw bytes which + // can be fed into btoa. + return btoa(encodeURIComponent(str) + .replace(/%([0-9A-F]{2})/g, + (match, p1) => { return String.fromCharCode('0x' + p1) })) +} + // Params // cropH // cropW @@ -156,7 +166,7 @@ const register = (params) => { const authHeaders = (user) => { if (user && user.username && user.password) { - return { 'Authorization': `Basic ${btoa(`${user.username}:${user.password}`)}` } + return { 'Authorization': `Basic ${utoa(`${user.username}:${user.password}`)}` } } else { return { } } From 0e51fac2b24c752513afe65736e98eb5fb5ec3af Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 5 Dec 2017 11:02:41 +0100 Subject: [PATCH 16/29] Add missing component code. --- src/components/chat/chat.js | 26 +++++++++++++++++++ src/components/chat/chat.vue | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/components/chat/chat.js create mode 100644 src/components/chat/chat.vue diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js new file mode 100644 index 00000000..3b84bd3d --- /dev/null +++ b/src/components/chat/chat.js @@ -0,0 +1,26 @@ +const chat = { + data () { + return { + messages: [], + currentMessage: '', + socket: this.$store.state.users.socket, + channel: null + } + }, + created () { + this.channel = this.socket.channel('chat:public') + this.channel.on('new_msg', (msg) => { + this.messages.push(msg) + this.messages = this.messages.slice(-19, 20) + }) + this.channel.join() + }, + methods: { + submit(message) { + this.channel.push('new_msg', {text: message}, 10000) + this.currentMessage = ''; + } + } +} + +export default chat; diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue new file mode 100644 index 00000000..9d3ab39c --- /dev/null +++ b/src/components/chat/chat.vue @@ -0,0 +1,49 @@ + + + + + + From 27be1e0fa3a9779a624012a8528801679721cb40 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 5 Dec 2017 11:47:10 +0100 Subject: [PATCH 17/29] Move chat to own module. --- src/components/chat/chat.js | 15 +++++---------- src/main.js | 4 +++- src/modules/api.js | 13 ++++++++++++- src/modules/chat.js | 33 +++++++++++++++++++++++++++++++++ src/modules/users.js | 12 ++---------- 5 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 src/modules/chat.js diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index 3b84bd3d..fc942a30 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -1,23 +1,18 @@ const chat = { data () { return { - messages: [], currentMessage: '', - socket: this.$store.state.users.socket, channel: null } }, - created () { - this.channel = this.socket.channel('chat:public') - this.channel.on('new_msg', (msg) => { - this.messages.push(msg) - this.messages = this.messages.slice(-19, 20) - }) - this.channel.join() + computed: { + messages () { + return this.$store.state.chat.messages + } }, methods: { submit(message) { - this.channel.push('new_msg', {text: message}, 10000) + this.$store.state.chat.channel.push('new_msg', {text: message}, 10000) this.currentMessage = ''; } } diff --git a/src/main.js b/src/main.js index ca3bb955..72b75a52 100644 --- a/src/main.js +++ b/src/main.js @@ -18,6 +18,7 @@ import statusesModule from './modules/statuses.js' import usersModule from './modules/users.js' import apiModule from './modules/api.js' import configModule from './modules/config.js' +import chatModule from './modules/chat.js' import VueTimeago from 'vue-timeago' import VueI18n from 'vue-i18n' @@ -58,7 +59,8 @@ const store = new Vuex.Store({ statuses: statusesModule, users: usersModule, api: apiModule, - config: configModule + config: configModule, + chat: chatModule }, plugins: [createPersistedState(persistedStateOptions)], strict: false // Socket modifies itself, let's ignore this for now. diff --git a/src/modules/api.js b/src/modules/api.js index e61382eb..ccd6cfb7 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -1,10 +1,12 @@ import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import {isArray} from 'lodash' +import { Socket } from 'phoenix' const api = { state: { backendInteractor: backendInteractorService(), - fetchers: {} + fetchers: {}, + socket: null }, mutations: { setBackendInteractor (state, backendInteractor) { @@ -15,6 +17,9 @@ const api = { }, removeFetcher (state, {timeline}) { delete state.fetchers[timeline] + }, + setSocket (state, socket) { + state.socket = socket } }, actions: { @@ -37,6 +42,12 @@ const api = { const fetcher = store.state.fetchers[timeline] window.clearInterval(fetcher) store.commit('removeFetcher', {timeline}) + }, + initializeSocket (store, token) { + // Set up websocket connection + let socket = new Socket('/socket', {params: {token: token}}) + socket.connect() + store.dispatch('initializeChat', socket) } } } diff --git a/src/modules/chat.js b/src/modules/chat.js new file mode 100644 index 00000000..b1244ebe --- /dev/null +++ b/src/modules/chat.js @@ -0,0 +1,33 @@ +const chat = { + state: { + messages: [], + channel: null + }, + mutations: { + setChannel (state, channel) { + state.channel = channel + }, + addMessage (state, message) { + state.messages.push(message) + state.messages = state.messages.slice(-19, 20) + }, + setMessages (state, messages) { + state.messages = messages.slice(-19, 20) + } + }, + actions: { + initializeChat (store, socket) { + const channel = socket.channel('chat:public') + channel.on('new_msg', (msg) => { + store.commit('addMessage', msg) + }) + channel.on('messages', ({messages}) => { + store.commit('setMessages', messages) + }) + channel.join() + store.commit('setChannel', channel) + } + } +} + +export default chat diff --git a/src/modules/users.js b/src/modules/users.js index a75271a4..8303ecc1 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -1,7 +1,6 @@ import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import { compact, map, each, merge } from 'lodash' import { set } from 'vue' -import { Socket } from 'phoenix' // TODO: Unify with mergeOrAdd in statuses.js export const mergeOrAdd = (arr, obj, item) => { @@ -20,9 +19,6 @@ export const mergeOrAdd = (arr, obj, item) => { } export const mutations = { - setSocket (state, socket) { - state.socket = socket - }, setMuted (state, { user: {id}, muted }) { const user = state.usersObject[id] set(user, 'muted', muted) @@ -54,8 +50,7 @@ export const defaultState = { currentUser: false, loggingIn: false, users: [], - usersObject: {}, - socket: null + usersObject: {} } const users = { @@ -103,10 +98,7 @@ const users = { commit('setBackendInteractor', backendInteractorService(userCredentials)) if (user.token) { - // Set up websocket connection - let socket = new Socket('/socket', {params: {token: user.token}}) - socket.connect() - store.commit('setSocket', socket) + store.dispatch('initializeSocket', user.token) } // Start getting fresh tweets. From 6ad27959a696ea0e4f6fe43a98daf4b99bb973ff Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 5 Dec 2017 11:49:40 +0100 Subject: [PATCH 18/29] Linting. --- src/components/chat/chat.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index fc942a30..ef326d4a 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -11,11 +11,11 @@ const chat = { } }, methods: { - submit(message) { + submit (message) { this.$store.state.chat.channel.push('new_msg', {text: message}, 10000) - this.currentMessage = ''; + this.currentMessage = '' } } } -export default chat; +export default chat From a03b92e252406a8469a9ffe871a6882b3aedb366 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 5 Dec 2017 12:09:54 +0100 Subject: [PATCH 19/29] Post on submit, not on enter. --- src/components/chat/chat.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index 9d3ab39c..0c397472 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -18,7 +18,9 @@
  • - + + +
    @@ -41,9 +43,12 @@ } .chat-input { display: flex; - input { + form { flex: auto; - margin: 0.5em; + input { + margin: 0.5em; + width: 100%; + } } } From 6c4e3a509a23a4f683aee02fcd0b186813ae3de0 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 5 Dec 2017 14:20:34 +0100 Subject: [PATCH 20/29] Don't display if we don't have a chat. --- src/components/chat/chat.vue | 2 +- src/components/nav_panel/nav_panel.js | 3 +++ src/components/nav_panel/nav_panel.vue | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index 0c397472..488faf9a 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -7,7 +7,7 @@
    -
    +
    {{message.author.username}}: diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index baeaaede..ea5d7ea4 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -2,6 +2,9 @@ const NavPanel = { computed: { currentUser () { return this.$store.state.users.currentUser + }, + chat () { + return this.$store.state.chat.channel } } } diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index fa4000b0..ccc772a8 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -7,7 +7,7 @@ {{ $t("nav.timeline") }} -
  • +
  • {{ $t("nav.chat") }} From 612fb183671783c3ac3eeea21428c024a47713b1 Mon Sep 17 00:00:00 2001 From: eal Date: Thu, 7 Dec 2017 18:20:44 +0200 Subject: [PATCH 21/29] Add option for disabling chat. --- src/main.js | 3 +++ src/modules/api.js | 17 +++++++++++++---- static/config.json | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index 72b75a52..a8ee5fda 100644 --- a/src/main.js +++ b/src/main.js @@ -82,6 +82,9 @@ window.fetch('/static/config.json') store.dispatch('setOption', { name: 'background', value: background }) store.dispatch('setOption', { name: 'logo', value: logo }) store.dispatch('setOption', { name: 'registrationOpen', value: registrationOpen }) + if (data['chatDisabled']) { + store.dispatch('disableChat') + } const routes = [ { name: 'root', path: '/', redirect: data['defaultPath'] || '/main/all' }, diff --git a/src/modules/api.js b/src/modules/api.js index ccd6cfb7..c91fb97b 100644 --- a/src/modules/api.js +++ b/src/modules/api.js @@ -6,7 +6,8 @@ const api = { state: { backendInteractor: backendInteractorService(), fetchers: {}, - socket: null + socket: null, + chatDisabled: false }, mutations: { setBackendInteractor (state, backendInteractor) { @@ -20,6 +21,9 @@ const api = { }, setSocket (state, socket) { state.socket = socket + }, + setChatDisabled (state, value) { + state.chatDisabled = value } }, actions: { @@ -45,9 +49,14 @@ const api = { }, initializeSocket (store, token) { // Set up websocket connection - let socket = new Socket('/socket', {params: {token: token}}) - socket.connect() - store.dispatch('initializeChat', socket) + if (!store.state.chatDisabled) { + let socket = new Socket('/socket', {params: {token: token}}) + socket.connect() + store.dispatch('initializeChat', socket) + } + }, + disableChat (store) { + store.commit('setChatDisabled', true) } } } diff --git a/static/config.json b/static/config.json index b186246b..880efca8 100644 --- a/static/config.json +++ b/static/config.json @@ -4,5 +4,6 @@ "background": "/static/bg.jpg", "logo": "/static/logo.png", "registrationOpen": false, - "defaultPath": "/main/all" + "defaultPath": "/main/all", + "chatDisabled": false } From ecb8acb155a77092b0661854b0ca4cf3c19ff56e Mon Sep 17 00:00:00 2001 From: eal Date: Thu, 7 Dec 2017 19:03:26 +0200 Subject: [PATCH 22/29] Some css fixes. Scale chat panel size to viewport height, fit message field to width. --- src/components/chat/chat.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index 488faf9a..6c1e2c38 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -30,6 +30,11 @@