refactor: refactor dialogs (#1015)

This commit is contained in:
Nolan Lawson 2019-02-18 16:27:59 -08:00 committed by GitHub
parent bfdb977f22
commit d665134d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 59 additions and 110 deletions

View File

@ -1,18 +1,12 @@
import AccountProfileOptionsDialog from '../components/AccountProfileOptionsDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showAccountProfileOptionsDialog (account, relationship, verifyCredentials) {
let dialog = new AccountProfileOptionsDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Profile options dialog',
title: '',
account: account,
relationship: relationship,
verifyCredentials: verifyCredentials
}
return showDialog(AccountProfileOptionsDialog, {
label: 'Profile options dialog',
title: '',
account: account,
relationship: relationship,
verifyCredentials: verifyCredentials
})
dialog.show()
}

View File

@ -1,14 +1,6 @@
import ComposeDialog from '../components/ComposeDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showComposeDialog () {
let dialog = new ComposeDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Compose dialog'
}
})
dialog.show()
return showDialog(ComposeDialog, { label: 'Compose dialog' })
}

View File

@ -1,16 +1,10 @@
import CopyDialog from '../components/CopyDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showCopyDialog (text) {
let dialog = new CopyDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Copy dialog',
title: 'Copy link',
text
}
return showDialog(CopyDialog, {
label: 'Copy dialog',
title: 'Copy link',
text
})
dialog.show()
}

View File

@ -0,0 +1,13 @@
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
export function showDialog (Dialog, data) {
let dialog = new Dialog({
target: createDialogElement(),
data: Object.assign({
id: createDialogId()
}, data)
})
dialog.show()
return dialog
}

View File

@ -1,16 +1,10 @@
import EmojiDialog from '../components/EmojiDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showEmojiDialog (realm) {
let emojiDialog = new EmojiDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Emoji dialog',
title: 'Emoji',
realm
}
return showDialog(EmojiDialog, {
label: 'Emoji dialog',
title: 'Emoji',
realm
})
emojiDialog.show()
}

View File

@ -1,16 +1,10 @@
import MediaDialog from '../components/MediaDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showMediaDialog (mediaItems, scrolledItem) {
let dialog = new MediaDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Media dialog',
mediaItems,
scrolledItem
}
return showDialog(MediaDialog, {
label: 'Media dialog',
mediaItems,
scrolledItem
})
dialog.show()
}

View File

@ -1,16 +1,9 @@
import MuteDialog from '../components/MuteDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showMuteDialog (account) {
let dialog = new MuteDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Mute dialog',
account
}
return showDialog(MuteDialog, {
label: 'Mute dialog',
account
})
dialog.show()
return dialog
}

View File

@ -1,16 +1,10 @@
import PostPrivacyDialog from '../components/PostPrivacyDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showPostPrivacyDialog (realm) {
let dialog = new PostPrivacyDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Post privacy dialog',
title: 'Post privacy',
realm: realm
}
return showDialog(PostPrivacyDialog, {
label: 'Post privacy dialog',
title: 'Post privacy',
realm: realm
})
dialog.show()
}

View File

@ -1,14 +1,8 @@
import ShortcutHelpDialog from '../components/ShortcutHelpDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showShortcutHelpDialog (options) {
let dialog = new ShortcutHelpDialog({
target: createDialogElement(),
data: Object.assign({
id: createDialogId(),
label: 'shortcut help dialog'
}, options)
})
dialog.show()
return showDialog(ShortcutHelpDialog, Object.assign({
label: 'shortcut help dialog'
}, options))
}

View File

@ -1,16 +1,10 @@
import StatusOptionsDialog from '../components/StatusOptionsDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showStatusOptionsDialog (status) {
let dialog = new StatusOptionsDialog({
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Status options dialog',
title: '',
status: status
}
return showDialog(StatusOptionsDialog, {
label: 'Status options dialog',
title: '',
status: status
})
dialog.show()
}

View File

@ -1,15 +1,8 @@
import TextConfirmationDialog from '../components/TextConfirmationDialog.html'
import { createDialogElement } from '../helpers/createDialogElement'
import { createDialogId } from '../helpers/createDialogId'
import { showDialog } from './showDialog'
export default function showTextConfirmationDialog (options) {
let dialog = new TextConfirmationDialog({
target: createDialogElement(),
data: Object.assign({
id: createDialogId(),
label: 'Confirmation dialog'
}, options)
})
dialog.show()
return dialog
return showDialog(TextConfirmationDialog, Object.assign({
label: 'Confirmation dialog'
}, options))
}