-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deep link to start private message (#206)
- Loading branch information
Showing
12 changed files
with
91 additions
and
3,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Extend from 'flarum/common/extenders'; | ||
import commonExtend from '../common/extend'; | ||
|
||
export default [...commonExtend]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Extend from 'flarum/common/extenders'; | ||
|
||
export default []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import app from 'flarum/forum/app'; | ||
import Page from 'flarum/common/components/Page'; | ||
import type Mithril from 'mithril'; | ||
import LogInModal from 'flarum/forum/components/LogInModal'; | ||
import PrivateDiscussionComposer from '../pages/discussions/PrivateDiscussionComposer'; | ||
import ItemList from 'flarum/common/utils/ItemList'; | ||
import Group from 'flarum/common/models/Group'; | ||
import User from 'flarum/common/models/User'; | ||
|
||
export default class PrivateComposerPage extends Page { | ||
oninit(vnode: Mithril.Vnode) { | ||
super.oninit(vnode); | ||
|
||
this.configComposer(); | ||
} | ||
|
||
configComposer() { | ||
if (!app.session.user) { | ||
setTimeout(() => app.modal.show(LogInModal), 500); | ||
return m.route.set('/'); | ||
} | ||
|
||
const params = m.route.param(); | ||
const recipients = new ItemList<User | Group>(); | ||
|
||
recipients.add(`users:${app.session.user.id()}`, app.session.user); | ||
|
||
m.route.set(app.route('byobuPrivate')); | ||
|
||
setTimeout(() => { | ||
const composerProps = { | ||
user: app.session.user, | ||
recipients: recipients, | ||
originalContent: null, | ||
}; | ||
|
||
if (params.content) { | ||
composerProps.originalContent = params.content; | ||
} | ||
|
||
if (params.recipientUsers) { | ||
params.recipientUsers.split(',').forEach((u: string) => { | ||
const su = app.store.getById<User>('users', u); | ||
if (!su) return; | ||
recipients.add(`users:${u}`, su); | ||
}); | ||
} | ||
|
||
if (params.recipientGroups) { | ||
params.recipientGroups.split(',').forEach((g: string) => { | ||
const sg = app.store.getById<Group>('groups', g); | ||
if (!sg) return; | ||
recipients.add(`groups:${g}`, sg); | ||
}); | ||
} | ||
|
||
app.composer.load(PrivateDiscussionComposer, composerProps); | ||
|
||
app.composer.show(); | ||
|
||
if (params.title) { | ||
// @ts-expect-error | ||
app.composer.fields?.title(params.title); | ||
} | ||
}, 0); | ||
} | ||
|
||
view() { | ||
return <div />; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters