Improve waiting dialog
This commit is contained in:
parent
85a0f696bc
commit
1df7abfbb9
8 changed files with 110 additions and 131 deletions
|
@ -6,26 +6,20 @@
|
|||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import * as os from '@/os';
|
||||
import parseAcct from '../../misc/acct/parse';
|
||||
|
||||
export default defineComponent({
|
||||
created() {
|
||||
const acct = new URL(location.href).searchParams.get('acct');
|
||||
if (acct == null) return;
|
||||
|
||||
/*
|
||||
const dialog = os.dialog({
|
||||
type: 'waiting',
|
||||
text: this.$t('fetchingAsApObject') + '...',
|
||||
showOkButton: false,
|
||||
showCancelButton: false,
|
||||
cancelableByBgClick: false
|
||||
});
|
||||
*/
|
||||
let promise;
|
||||
|
||||
if (acct.startsWith('https://')) {
|
||||
os.api('ap/show', {
|
||||
promise = os.api('ap/show', {
|
||||
uri: acct
|
||||
}).then(res => {
|
||||
});
|
||||
promise.then(res => {
|
||||
if (res.type == 'User') {
|
||||
this.follow(res.object);
|
||||
} else if (res.type === 'Note') {
|
||||
|
@ -38,30 +32,15 @@ export default defineComponent({
|
|||
window.close();
|
||||
});
|
||||
}
|
||||
}).catch(e => {
|
||||
os.dialog({
|
||||
type: 'error',
|
||||
text: e
|
||||
}).then(() => {
|
||||
window.close();
|
||||
});
|
||||
}).finally(() => {
|
||||
//dialog.close();
|
||||
});
|
||||
} else {
|
||||
os.api('users/show', parseAcct(acct)).then(user => {
|
||||
promise = os.api('users/show', parseAcct(acct));
|
||||
promise.then(user => {
|
||||
this.follow(user);
|
||||
}).catch(e => {
|
||||
os.dialog({
|
||||
type: 'error',
|
||||
text: e
|
||||
}).then(() => {
|
||||
window.close();
|
||||
});
|
||||
}).finally(() => {
|
||||
//dialog.close();
|
||||
});
|
||||
}
|
||||
|
||||
os.promiseDialog(promise, null, null, this.$t('fetchingAsApObject'));
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
@ -77,19 +56,8 @@ export default defineComponent({
|
|||
return;
|
||||
}
|
||||
|
||||
os.api('following/create', {
|
||||
os.apiWithDialog('following/create', {
|
||||
userId: user.id
|
||||
}).then(() => {
|
||||
os.success().then(() => {
|
||||
window.close();
|
||||
});
|
||||
}).catch(e => {
|
||||
os.dialog({
|
||||
type: 'error',
|
||||
text: e
|
||||
}).then(() => {
|
||||
window.close();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,24 +106,13 @@ export default defineComponent({
|
|||
async add(e) {
|
||||
const files = await selectFile(e.currentTarget || e.target, null, true);
|
||||
|
||||
const dialog = os.dialog({
|
||||
type: 'waiting',
|
||||
text: this.$t('doing') + '...',
|
||||
showOkButton: false,
|
||||
showCancelButton: false,
|
||||
cancelableByBgClick: false
|
||||
});
|
||||
|
||||
Promise.all(files.map(file => os.api('admin/emoji/add', {
|
||||
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
||||
fileId: file.id,
|
||||
})))
|
||||
.then(() => {
|
||||
})));
|
||||
promise.then(() => {
|
||||
this.$refs.emojis.reload();
|
||||
os.success();
|
||||
})
|
||||
.finally(() => {
|
||||
dialog.cancel();
|
||||
});
|
||||
os.promiseDialog(promise);
|
||||
},
|
||||
|
||||
async edit(emoji) {
|
||||
|
|
|
@ -69,31 +69,15 @@ export default defineComponent({
|
|||
data.append('file', file);
|
||||
data.append('i', this.$store.state.i.token);
|
||||
|
||||
const dialog = os.dialog({
|
||||
type: 'waiting',
|
||||
text: this.$t('uploading') + '...',
|
||||
showOkButton: false,
|
||||
showCancelButton: false,
|
||||
cancelableByBgClick: false
|
||||
});
|
||||
|
||||
fetch(apiUrl + '/drive/files/create', {
|
||||
const promise = fetch(apiUrl + '/drive/files/create', {
|
||||
method: 'POST',
|
||||
body: data
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(f => {
|
||||
this.reqImport(f);
|
||||
})
|
||||
.catch(e => {
|
||||
os.dialog({
|
||||
type: 'error',
|
||||
text: e
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
dialog.close();
|
||||
});
|
||||
os.promiseDialog(promise);
|
||||
},
|
||||
|
||||
reqImport(file) {
|
||||
|
|
|
@ -106,6 +106,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="_card _vMargin">
|
||||
<div class="_title">Waiting dialog</div>
|
||||
<div class="_content">
|
||||
<MkButton inline @click="openWaitingDialog()">icon only</MkButton>
|
||||
<MkButton inline @click="openWaitingDialog('Doing')">with text</MkButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="_card _vMargin">
|
||||
<div class="_title">Messaging window</div>
|
||||
<div class="_content">
|
||||
|
@ -224,6 +232,13 @@ export default defineComponent({
|
|||
os.pageWindow('/my/messaging', defineAsyncComponent(() => import('@/pages/messaging/index.vue')));
|
||||
},
|
||||
|
||||
openWaitingDialog(text?) {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
setTimeout(resolve, 2000);
|
||||
});
|
||||
os.promiseDialog(promise, null, null, text);
|
||||
},
|
||||
|
||||
resetTutorial() {
|
||||
this.$store.dispatch('settings/set', { key: 'tutorial', value: 0 });
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue