From 555a0f276cfabfc5288bb76bdf1274cf9e7fb8d4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 16 Jun 2018 18:42:49 +0900 Subject: [PATCH] MisskeyShare --- package.json | 1 - .../app/desktop/api/choose-drive-file.ts | 2 +- src/client/app/desktop/script.ts | 2 + .../desktop/views/components/post-form.vue | 48 +++++++++++---- src/client/app/desktop/views/pages/share.vue | 58 +++++++++++++++++++ src/client/app/mobile/script.ts | 2 + .../app/mobile/views/components/index.ts | 2 + .../app/mobile/views/components/post-form.vue | 30 +++++++++- src/client/app/mobile/views/pages/share.vue | 56 ++++++++++++++++++ 9 files changed, 185 insertions(+), 16 deletions(-) create mode 100644 src/client/app/desktop/views/pages/share.vue create mode 100644 src/client/app/mobile/views/pages/share.vue diff --git a/package.json b/package.json index fac4383d9..ca6f0387f 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,6 @@ "websocket": "1.0.26", "ws": "5.2.0", "xev": "2.0.1", - "@prezzemolo/zip": "0.0.3", "@types/bcryptjs": "2.4.1", "@types/debug": "0.0.30", diff --git a/src/client/app/desktop/api/choose-drive-file.ts b/src/client/app/desktop/api/choose-drive-file.ts index 3d0004b74..a362a1289 100644 --- a/src/client/app/desktop/api/choose-drive-file.ts +++ b/src/client/app/desktop/api/choose-drive-file.ts @@ -21,7 +21,7 @@ export default (os: OS) => opts => { res(file); }; - window.open(url + '/selectdrive', + window.open(url + `/selectdrive?multiple=${o.multiple}`, 'choose_drive_window', 'height=500, width=800'); } diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts index 8b1623ce4..076d532d6 100644 --- a/src/client/app/desktop/script.ts +++ b/src/client/app/desktop/script.ts @@ -35,6 +35,7 @@ import MkNote from './views/pages/note.vue'; import MkSearch from './views/pages/search.vue'; import MkTag from './views/pages/tag.vue'; import MkOthello from './views/pages/othello.vue'; +import MkShare from './views/pages/share.vue'; /** * init @@ -62,6 +63,7 @@ init(async (launch) => { { path: '/selectdrive', component: MkSelectDrive }, { path: '/search', component: MkSearch }, { path: '/tags/:tag', component: MkTag }, + { path: '/share', component: MkShare }, { path: '/othello', component: MkOthello }, { path: '/othello/:game', component: MkOthello }, { path: '/@:user', component: MkUser }, diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index a0670a084..33f2288e0 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -58,7 +58,25 @@ export default Vue.extend({ MkVisibilityChooser }, - props: ['reply', 'renote'], + props: { + reply: { + type: Object, + required: false + }, + renote: { + type: Object, + required: false + }, + initialText: { + type: String, + required: false + }, + instant: { + type: Boolean, + required: false, + default: false + } + }, data() { return { @@ -118,6 +136,10 @@ export default Vue.extend({ }, mounted() { + if (this.initialText) { + this.text = this.initialText; + } + if (this.reply && this.reply.user.host != null) { this.text = `@${this.reply.user.username}@${this.reply.user.host} `; } @@ -141,17 +163,19 @@ export default Vue.extend({ this.$nextTick(() => { // 書きかけの投稿を復元 - const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[this.draftId]; - if (draft) { - this.text = draft.data.text; - this.files = draft.data.files; - if (draft.data.poll) { - this.poll = true; - this.$nextTick(() => { - (this.$refs.poll as any).set(draft.data.poll); - }); + if (!this.instant) { + const draft = JSON.parse(localStorage.getItem('drafts') || '{}')[this.draftId]; + if (draft) { + this.text = draft.data.text; + this.files = draft.data.files; + if (draft.data.poll) { + this.poll = true; + this.$nextTick(() => { + (this.$refs.poll as any).set(draft.data.poll); + }); + } + this.$emit('change-attached-media', this.files); } - this.$emit('change-attached-media', this.files); } this.$nextTick(() => this.watch()); @@ -349,6 +373,8 @@ export default Vue.extend({ }, saveDraft() { + if (this.instant) return; + const data = JSON.parse(localStorage.getItem('drafts') || '{}'); data[this.draftId] = { diff --git a/src/client/app/desktop/views/pages/share.vue b/src/client/app/desktop/views/pages/share.vue new file mode 100644 index 000000000..e60434074 --- /dev/null +++ b/src/client/app/desktop/views/pages/share.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/client/app/mobile/script.ts b/src/client/app/mobile/script.ts index 8ee078d62..1572fd73e 100644 --- a/src/client/app/mobile/script.ts +++ b/src/client/app/mobile/script.ts @@ -37,6 +37,7 @@ import MkUserList from './views/pages/user-list.vue'; import MkSettings from './views/pages/settings.vue'; import MkOthello from './views/pages/othello.vue'; import MkTag from './views/pages/tag.vue'; +import MkShare from './views/pages/share.vue'; /** * init @@ -73,6 +74,7 @@ init((launch) => { { path: '/selectdrive', component: MkSelectDrive }, { path: '/search', component: MkSearch }, { path: '/tags/:tag', component: MkTag }, + { path: '/share', component: MkShare }, { path: '/othello', name: 'othello', component: MkOthello }, { path: '/othello/:game', component: MkOthello }, { path: '/@:user', component: MkUser }, diff --git a/src/client/app/mobile/views/components/index.ts b/src/client/app/mobile/views/components/index.ts index 5ed8427b0..38c130ecb 100644 --- a/src/client/app/mobile/views/components/index.ts +++ b/src/client/app/mobile/views/components/index.ts @@ -22,6 +22,7 @@ import userTimeline from './user-timeline.vue'; import userListTimeline from './user-list-timeline.vue'; import activity from './activity.vue'; import widgetContainer from './widget-container.vue'; +import postForm from './post-form.vue'; Vue.component('mk-ui', ui); Vue.component('mk-note', note); @@ -45,3 +46,4 @@ Vue.component('mk-user-timeline', userTimeline); Vue.component('mk-user-list-timeline', userListTimeline); Vue.component('mk-activity', activity); Vue.component('mk-widget-container', widgetContainer); +Vue.component('mk-post-form', postForm); diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index 88853fa23..62fa18508 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -54,7 +54,25 @@ export default Vue.extend({ MkVisibilityChooser }, - props: ['reply', 'renote'], + props: { + reply: { + type: Object, + required: false + }, + renote: { + type: Object, + required: false + }, + initialText: { + type: String, + required: false + }, + instant: { + type: Boolean, + required: false, + default: false + } + }, data() { return { @@ -112,6 +130,10 @@ export default Vue.extend({ }, mounted() { + if (this.initialText) { + this.text = this.initialText; + } + if (this.reply && this.reply.user.host != null) { this.text = `@${this.reply.user.username}@${this.reply.user.host} `; } @@ -252,8 +274,10 @@ export default Vue.extend({ visibleUserIds: this.visibility == 'specified' ? this.visibleUsers.map(u => u.id) : undefined, viaMobile: viaMobile }).then(data => { - this.$emit('note'); - this.$destroy(); + this.$emit('posted'); + this.$nextTick(() => { + this.$destroy(); + }); }).catch(err => { this.posting = false; }); diff --git a/src/client/app/mobile/views/pages/share.vue b/src/client/app/mobile/views/pages/share.vue new file mode 100644 index 000000000..c69498007 --- /dev/null +++ b/src/client/app/mobile/views/pages/share.vue @@ -0,0 +1,56 @@ + + + + +