From ff7bb97d8ee04a6a56aaea8a09f9b4d7170f2064 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 10 Feb 2018 10:27:05 +0900 Subject: wip --- src/api/bot/core.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/api') diff --git a/src/api/bot/core.ts b/src/api/bot/core.ts index ddae6405f5..0a073a3127 100644 --- a/src/api/bot/core.ts +++ b/src/api/bot/core.ts @@ -305,7 +305,7 @@ class TlContext extends Context { private async getTl() { const tl = await require('../endpoints/posts/timeline')({ limit: 5, - max_id: this.next ? this.next : undefined + until_id: this.next ? this.next : undefined }, this.bot.user); if (tl.length > 0) { @@ -357,7 +357,7 @@ class NotificationsContext extends Context { private async getNotifications() { const notifications = await require('../endpoints/i/notifications')({ limit: 5, - max_id: this.next ? this.next : undefined + until_id: this.next ? this.next : undefined }, this.bot.user); if (notifications.length > 0) { -- cgit v1.2.3-freya From e0ffedca240309bada9dcd7e53e66cc804e2912d Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 23 Feb 2018 01:27:02 +0900 Subject: wip --- src/api/private/signup.ts | 6 ++--- src/web/app/desktop/views/components/dialog.vue | 29 ++++++++++++---------- .../app/desktop/views/components/post-preview.vue | 1 - 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'src/api') diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts index 8efdb6db47..19e3314756 100644 --- a/src/api/private/signup.ts +++ b/src/api/private/signup.ts @@ -15,7 +15,7 @@ const home = { 'profile', 'calendar', 'activity', - 'rss-reader', + 'rss', 'trends', 'photo-stream', 'version' @@ -23,8 +23,8 @@ const home = { right: [ 'broadcast', 'notifications', - 'user-recommendation', - 'recommended-polls', + 'users', + 'polls', 'server', 'donation', 'nav', diff --git a/src/web/app/desktop/views/components/dialog.vue b/src/web/app/desktop/views/components/dialog.vue index f089b19a4e..28f22f7b62 100644 --- a/src/web/app/desktop/views/components/dialog.vue +++ b/src/web/app/desktop/views/components/dialog.vue @@ -2,7 +2,7 @@
-
+
@@ -110,18 +110,6 @@ export default Vue.extend({ background #fff opacity 0 - > header - margin 1em 0 - color $theme-color - // color #43A4EC - font-weight bold - - &:empty - display none - - > i - margin-right 0.5em - > .body margin 1em 0 color #888 @@ -154,3 +142,18 @@ export default Vue.extend({ transition color 0s ease + + diff --git a/src/web/app/desktop/views/components/post-preview.vue b/src/web/app/desktop/views/components/post-preview.vue index b39ad3db40..6a0a60e4af 100644 --- a/src/web/app/desktop/views/components/post-preview.vue +++ b/src/web/app/desktop/views/components/post-preview.vue @@ -64,7 +64,6 @@ export default Vue.extend({ > header display flex - margin 4px 0 white-space nowrap > .name -- cgit v1.2.3-freya From c686a1047248749b21c76fd9f5d867c9324cdd82 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 23 Feb 2018 02:06:35 +0900 Subject: wip --- src/api/endpoints.ts | 5 ++ src/api/endpoints/i/update.ts | 8 +--- src/api/endpoints/i/update_client_setting.ts | 43 +++++++++++++++++ src/web/app/common/views/components/post-html.ts | 6 ++- src/web/app/desktop/views/components/home.vue | 54 +++++++++++++--------- .../desktop/views/components/settings-window.vue | 12 +++-- src/web/app/desktop/views/components/settings.vue | 33 ++++++++++++- 7 files changed, 127 insertions(+), 34 deletions(-) create mode 100644 src/api/endpoints/i/update_client_setting.ts (limited to 'src/api') diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index e846381578..ff214c3004 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -194,6 +194,11 @@ const endpoints: Endpoint[] = [ withCredential: true, secure: true }, + { + name: 'i/update_client_setting', + withCredential: true, + secure: true + }, { name: 'i/pin', kind: 'account-write' diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts index 7bbbf95900..43c5245044 100644 --- a/src/api/endpoints/i/update.ts +++ b/src/api/endpoints/i/update.ts @@ -46,19 +46,13 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re if (bannerIdErr) return rej('invalid banner_id param'); if (bannerId) user.banner_id = bannerId; - // Get 'show_donation' parameter - const [showDonation, showDonationErr] = $(params.show_donation).optional.boolean().$; - if (showDonationErr) return rej('invalid show_donation param'); - if (showDonation) user.client_settings.show_donation = showDonation; - await User.update(user._id, { $set: { name: user.name, description: user.description, avatar_id: user.avatar_id, banner_id: user.banner_id, - profile: user.profile, - 'client_settings.show_donation': user.client_settings.show_donation + profile: user.profile } }); diff --git a/src/api/endpoints/i/update_client_setting.ts b/src/api/endpoints/i/update_client_setting.ts new file mode 100644 index 0000000000..b817ff354c --- /dev/null +++ b/src/api/endpoints/i/update_client_setting.ts @@ -0,0 +1,43 @@ +/** + * Module dependencies + */ +import $ from 'cafy'; +import User, { pack } from '../../models/user'; +import event from '../../event'; + +/** + * Update myself + * + * @param {any} params + * @param {any} user + * @return {Promise} + */ +module.exports = async (params, user) => new Promise(async (res, rej) => { + // Get 'name' parameter + const [name, nameErr] = $(params.name).string().$; + if (nameErr) return rej('invalid name param'); + + // Get 'value' parameter + const [value, valueErr] = $(params.value).nullable.any().$; + if (valueErr) return rej('invalid value param'); + + const x = {}; + x[`client_settings.${name}`] = value; + + await User.update(user._id, { + $set: x + }); + + // Serialize + user.client_settings[name] = value; + const iObj = await pack(user, user, { + detail: true, + includeSecrets: true + }); + + // Send response + res(iObj); + + // Publish i updated event + event(user._id, 'i_updated', iObj); +}); diff --git a/src/web/app/common/views/components/post-html.ts b/src/web/app/common/views/components/post-html.ts index afd95f8e38..16d670e851 100644 --- a/src/web/app/common/views/components/post-html.ts +++ b/src/web/app/common/views/components/post-html.ts @@ -33,7 +33,11 @@ export default Vue.component('mk-post-html', { .replace(/(\r\n|\n|\r)/g, '\n'); if ((this as any).shouldBreak) { - return text.split('\n').map(t => [createElement('span', t), createElement('br')]); + if (text.indexOf('\n') != -1) { + return text.split('\n').map(t => [createElement('span', t), createElement('br')]); + } else { + return createElement('span', text); + } } else { return createElement('span', text.replace(/\n/g, ' ')); } diff --git a/src/web/app/desktop/views/components/home.vue b/src/web/app/desktop/views/components/home.vue index eabcc485dd..8a61c378ed 100644 --- a/src/web/app/desktop/views/components/home.vue +++ b/src/web/app/desktop/views/components/home.vue @@ -1,7 +1,7 @@