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 AccountProfileOptionsDialog from '../components/AccountProfileOptionsDialog.html'
import { createDialogElement } from '../helpers/createDialogElement' import { showDialog } from './showDialog'
import { createDialogId } from '../helpers/createDialogId'
export default function showAccountProfileOptionsDialog (account, relationship, verifyCredentials) { export default function showAccountProfileOptionsDialog (account, relationship, verifyCredentials) {
let dialog = new AccountProfileOptionsDialog({ return showDialog(AccountProfileOptionsDialog, {
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Profile options dialog', label: 'Profile options dialog',
title: '', title: '',
account: account, account: account,
relationship: relationship, relationship: relationship,
verifyCredentials: verifyCredentials verifyCredentials: verifyCredentials
}
}) })
dialog.show()
} }

View file

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

View file

@ -1,16 +1,10 @@
import CopyDialog from '../components/CopyDialog.html' import CopyDialog from '../components/CopyDialog.html'
import { createDialogElement } from '../helpers/createDialogElement' import { showDialog } from './showDialog'
import { createDialogId } from '../helpers/createDialogId'
export default function showCopyDialog (text) { export default function showCopyDialog (text) {
let dialog = new CopyDialog({ return showDialog(CopyDialog, {
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Copy dialog', label: 'Copy dialog',
title: 'Copy link', title: 'Copy link',
text 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 EmojiDialog from '../components/EmojiDialog.html'
import { createDialogElement } from '../helpers/createDialogElement' import { showDialog } from './showDialog'
import { createDialogId } from '../helpers/createDialogId'
export default function showEmojiDialog (realm) { export default function showEmojiDialog (realm) {
let emojiDialog = new EmojiDialog({ return showDialog(EmojiDialog, {
target: createDialogElement(),
data: {
id: createDialogId(),
label: 'Emoji dialog', label: 'Emoji dialog',
title: 'Emoji', title: 'Emoji',
realm realm
}
}) })
emojiDialog.show()
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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