refactor: refactor dialogs (#1015)
This commit is contained in:
parent
bfdb977f22
commit
d665134d66
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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' })
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
13
src/routes/_components/dialog/creators/showDialog.js
Normal file
13
src/routes/_components/dialog/creators/showDialog.js
Normal 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
|
||||
}
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue