Merge branch 'develop'

This commit is contained in:
syuilo 2019-04-18 22:01:45 +09:00
commit 7b44727b23
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
39 changed files with 556 additions and 260 deletions

View file

@ -379,43 +379,30 @@ export default Vue.extend({
});
},
openContextMenu() {
const fn = window.prompt(this.$t('prompt'));
if (fn == null || fn == '') return;
switch (fn) {
case '1':
this.selectLocalFile();
break;
case '2':
this.urlUpload();
break;
case '3':
this.createFolder();
break;
case '4':
this.renameFolder();
break;
case '5':
this.moveFolder();
break;
case '6':
this.deleteFolder();
break;
}
},
selectLocalFile() {
(this.$refs.file as any).click();
},
createFolder() {
const name = window.prompt(this.$t('folder-name'));
if (name == null || name == '') return;
this.$root.api('drive/folders/create', {
name: name,
parentId: this.folder ? this.folder.id : undefined
}).then(folder => {
this.addFolder(folder, true);
this.$root.dialog({
title: this.$t('folder-name')
input: {
default: this.folder.name
}
}).then(({ result: name }) => {
if (!name) {
this.$root.dialog({
type: 'error',
text: this.$t('folder-name-cannot-empty')
});
return;
}
this.$root.api('drive/folders/create', {
name: name,
parentId: this.folder ? this.folder.id : undefined
}).then(folder => {
this.addFolder(folder, true);
});
});
},
@ -427,13 +414,25 @@ export default Vue.extend({
});
return;
}
const name = window.prompt(this.$t('folder-name'), this.folder.name);
if (name == null || name == '') return;
this.$root.api('drive/folders/update', {
name: name,
folderId: this.folder.id
}).then(folder => {
this.cd(folder);
this.$root.dialog({
title: this.$t('folder-name')
input: {
default: this.folder.name
}
}).then(({ result: name }) => {
if (!name) {
this.$root.dialog({
type: 'error',
text: this.$t('cannot-empty')
});
return;
}
this.$root.api('drive/folders/update', {
name: name,
folderId: this.folder.id
}).then(folder => {
this.cd(folder);
});
});
},

View file

@ -124,7 +124,7 @@ export default Vue.extend({
},
fetchMore() {
if (!this.more || this.moreFetching) return;
if (!this.more || this.moreFetching || this.notes.length === 0) return;
this.moreFetching = true;
this.makePromise(this.notes[this.notes.length - 1].id).then(x => {
this.notes = this.notes.concat(x.notes);

View file

@ -66,6 +66,7 @@ import i18n from '../../../i18n';
import { lang } from '../../../config';
import { faNewspaper, faHashtag, faHome, faColumns } from '@fortawesome/free-solid-svg-icons';
import { faMoon, faSun } from '@fortawesome/free-regular-svg-icons';
import { search } from '../../../common/scripts/search';
export default Vue.extend({
i18n: i18n('mobile/views/components/ui.nav.vue'),
@ -133,29 +134,10 @@ export default Vue.extend({
}).then(async ({ canceled, result: query }) => {
if (canceled) return;
const q = query.trim();
if (q.startsWith('@')) {
this.$router.push(`/${q}`);
} else if (q.startsWith('#')) {
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
} else if (q.startsWith('https://')) {
this.searching = true;
try {
const res = await this.$root.api('ap/show', {
uri: q
});
if (res.type == 'User') {
this.$router.push(`/@${res.object.username}@${res.object.host}`);
} else if (res.type == 'Note') {
this.$router.push(`/notes/${res.object.id}`);
}
} catch (e) {
// TODO
}
this.searching = true;
search(this, query).finally(() => {
this.searching = false;
} else {
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
}
});
});
},

View file

@ -15,10 +15,12 @@ export default Vue.extend({
data() {
return {
connection: null,
date: null,
makePromise: cursor => this.$root.api('notes/user-list-timeline', {
listId: this.list.id,
limit: fetchLimit + 1,
untilId: cursor ? cursor : undefined,
untilDate: cursor ? undefined : (this.date ? this.date.getTime() : undefined),
includeMyRenotes: this.$store.state.settings.showMyRenotes,
includeRenotedMyNotes: this.$store.state.settings.showRenotedMyNotes,
includeLocalRenotes: this.$store.state.settings.showLocalRenotes
@ -45,6 +47,11 @@ export default Vue.extend({
mounted() {
this.init();
this.$root.$on('warp', this.warp);
this.$once('hook:beforeDestroy', () => {
this.$root.$off('warp', this.warp);
});
},
beforeDestroy() {
@ -73,6 +80,11 @@ export default Vue.extend({
onUserRemoved() {
(this.$refs.timeline as any).reload();
},
warp(date) {
this.date = date;
(this.$refs.timeline as any).reload();
}
}
});

View file

@ -17,11 +17,13 @@ export default Vue.extend({
data() {
return {
date: null,
makePromise: cursor => this.$root.api('users/notes', {
userId: this.user.id,
limit: fetchLimit + 1,
withFiles: this.withMedia,
untilDate: cursor ? cursor : new Date().getTime() + 1000 * 86400 * 365
untilDate: cursor ? undefined : (this.date ? this.date.getTime() : undefined),
untilId: cursor ? cursor : undefined
}).then(notes => {
if (notes.length == fetchLimit + 1) {
notes.pop();
@ -37,6 +39,20 @@ export default Vue.extend({
}
})
};
},
created() {
this.$root.$on('warp', this.warp);
this.$once('hook:beforeDestroy', () => {
this.$root.$off('warp', this.warp);
});
},
methods: {
warp(date) {
this.date = date;
(this.$refs.timeline as any).reload();
}
}
});
</script>

View file

@ -5,7 +5,7 @@
<template v-if="file"><mk-file-type-icon data-icon :type="file.type" style="margin-right:4px;"/>{{ file.name }}</template>
<template v-if="!folder && !file"><span style="margin-right:4px;"><fa icon="cloud"/></span>{{ $t('@.drive') }}</template>
</template>
<template #func><button @click="fn"><fa icon="ellipsis-h"/></button></template>
<template #func v-if="folder || (!folder && !file)"><button @click="openContextMenu" ref="contextSource"><fa icon="ellipsis-h"/></button></template>
<x-drive
ref="browser"
:init-folder="initFolder"
@ -26,9 +26,12 @@
import Vue from 'vue';
import i18n from '../../../i18n';
import Progress from '../../../common/scripts/loading';
import XMenu from '../../../common/views/components/menu.vue';
import { faTrashAlt } from '@fortawesome/free-regular-svg-icons';
import { faCloudUploadAlt } from '@fortawesome/free-solid-svg-icons';
export default Vue.extend({
i18n: i18n(),
i18n: i18n('mobile/views/pages/drive.vue'),
components: {
XDrive: () => import('../components/drive.vue').then(m => m.default),
},
@ -63,9 +66,6 @@ export default Vue.extend({
(this.$refs as any).browser.goRoot(true);
}
},
fn() {
(this.$refs as any).browser.openContextMenu();
},
onMoveRoot(silent) {
const title = `${this.$root.instanceName} Drive`;
@ -104,6 +104,42 @@ export default Vue.extend({
this.file = file;
this.folder = null;
},
openContextMenu() {
this.$root.new(XMenu, {
items: [{
type: 'item',
text: this.$t('contextmenu.upload'),
icon: 'upload',
action: this.$refs.browser.selectLocalFile
}, {
type: 'item',
text: this.$t('contextmenu.url-upload'),
icon: faCloudUploadAlt,
action: this.$refs.browser.urlUpload
}, {
type: 'item',
text: this.$t('contextmenu.create-folder'),
icon: ['far', 'folder'],
action: this.$refs.browser.createFolder
}, ...(this.folder ? [{
type: 'item',
text: this.$t('contextmenu.rename-folder'),
icon: 'i-cursor',
action: this.$refs.browser.renameFolder
}, {
type: 'item',
text: this.$t('contextmenu.move-folder'),
icon: ['far', 'folder-open'],
action: this.$refs.browser.moveFolder
}, {
type: 'item',
text: this.$t('contextmenu.delete-folder'),
icon: faTrashAlt,
action: this.$refs.browser.deleteFolder
}] : [])],
source: this.$refs.contextSource,
});
}
}
});

View file

@ -54,6 +54,12 @@ export default Vue.extend({
},
created() {
this.$root.$on('warp', this.warp);
this.$once('hook:beforeDestroy', () => {
this.$root.$off('warp', this.warp);
this.connection.dispose();
});
const prepend = note => {
(this.$refs.timeline as any).prepend(note);
};
@ -125,10 +131,6 @@ export default Vue.extend({
});
},
beforeDestroy() {
this.connection.dispose();
},
methods: {
focus() {
(this.$refs.timeline as any).focus();

View file

@ -1,20 +1,15 @@
<template>
<mk-ui>
<template #header><fa icon="list"/>{{ $t('title') }}</template>
<template #func><button @click="fn"><fa icon="plus"/></button></template>
<template #func><button @click="$refs.lists.add()"><fa icon="plus"/></button></template>
<main>
<ul>
<li v-for="list in lists" :key="list.id"><router-link :to="`/i/lists/${list.id}`">{{ list.name }}</router-link></li>
</ul>
</main>
<x-lists ref="lists" @choosen="choosen"/>
</mk-ui>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
import Progress from '../../../common/scripts/loading';
export default Vue.extend({
i18n: i18n('mobile/views/pages/user-lists.vue'),
@ -24,31 +19,16 @@ export default Vue.extend({
lists: []
};
},
components: {
XLists: () => import('../../../common/views/components/user-lists.vue').then(m => m.default)
},
mounted() {
document.title = this.$t('title');
Progress.start();
this.$root.api('users/lists/list').then(lists => {
this.fetching = false;
this.lists = lists;
Progress.done();
});
},
methods: {
fn() {
this.$root.dialog({
title: this.$t('enter-list-name'),
input: true
}).then(async ({ canceled, result: title }) => {
if (canceled) return;
const list = await this.$root.api('users/lists/create', {
title
});
this.$router.push(`/i/lists/${list.id}`);
});
choosen(list) {
if (!list) return;
this.$router.push(`/i/lists/${list.id}`);
}
}
});

View file

@ -72,13 +72,13 @@ export default Vue.extend({
computed: {
widgets(): any[] {
return this.$store.state.settings.mobileHome;
return this.$store.state.device.mobileHome;
}
},
created() {
if (this.widgets.length == 0) {
this.widgets = [{
this.$store.commit('device/setMobileHome', [{
name: 'calendar',
id: 'a', data: {}
}, {
@ -96,8 +96,7 @@ export default Vue.extend({
}, {
name: 'version',
id: 'g', data: {}
}];
this.saveHome();
}]);
}
},
@ -123,7 +122,7 @@ export default Vue.extend({
},
addWidget() {
this.$store.commit('settings/addMobileHomeWidget', {
this.$store.commit('device/addMobileHomeWidget', {
name: this.widgetAdderSelected,
id: uuid(),
data: {}
@ -131,11 +130,11 @@ export default Vue.extend({
},
removeWidget(widget) {
this.$store.commit('settings/removeMobileHomeWidget', widget);
this.$store.commit('device/removeMobileHomeWidget', widget);
},
saveHome() {
this.$store.commit('settings/setMobileHome', this.widgets);
this.$store.commit('device/setMobileHome', this.widgets);
}
}
});