-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Localized notifications based on discussion language (#44)
* feat: Allow users to recieve notifications only about the discussions in the language of their choice * Apply fixes from StyleCI * fix: LanguageDropdown not displaying the label correctly when a tag language is set * fix: LanguageDropdown not updating it's state correctly, move all option entirely to the backend * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
a59585d
commit aa44b34
Showing
33 changed files
with
599 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,17 +19,22 @@ | |
} | ||
], | ||
"require": { | ||
"flarum/core": "^1.3.1", | ||
"fof/extend": "^1.0.0", | ||
"flarum/core": "^1.8.1", | ||
"rinvex/countries": "^6.1.2 || ^7.0.1 || ^8.1.0", | ||
"league/csv": "^9.7", | ||
"ianm/iso-639": "^1.0" | ||
"ianm/iso-639": "^1.0", | ||
"flarum/tags": "*" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "David Sevilla Martin", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
}, | ||
{ | ||
"name": "IanM", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
|
@@ -47,12 +52,16 @@ | |
"color": "#fff" | ||
}, | ||
"optional-dependencies": [ | ||
"flarum/tags", | ||
"fof/byobu" | ||
"fof/byobu", | ||
"fof/follow-tags" | ||
] | ||
}, | ||
"flagrow": { | ||
"discuss": "https://discuss.flarum.org/d/23702" | ||
} | ||
}, | ||
"require-dev": { | ||
"fof/byobu": "*", | ||
"fof/follow-tags": "*" | ||
} | ||
} |
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 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,21 @@ | ||
import Extend from 'flarum/common/extenders'; | ||
import Language from '../common/models/Language'; | ||
import Discussion from 'flarum/common/models/Discussion'; | ||
import Forum from 'flarum/common/models/Forum'; | ||
import Tag from 'flarum/tags/common/models/Tag'; | ||
|
||
export default [ | ||
new Extend.Store() // | ||
.add('discussion-languages', Language), | ||
|
||
new Extend.Model(Discussion) // | ||
.hasOne('language') | ||
.attribute<boolean>('canChangeLanguage'), | ||
|
||
new Extend.Model(Forum) // | ||
.hasMany<Language>('discussionLanguages'), | ||
|
||
new Extend.Model(Tag) // | ||
.attribute<string>('subscriptionLanguage') | ||
.attribute<string>('localisedLastDiscussion'), | ||
]; |
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,27 @@ | ||
import Model from 'flarum/common/Model'; | ||
|
||
export default class Language extends Model { | ||
id() { | ||
return Model.attribute<string>('id').call(this); | ||
} | ||
|
||
code() { | ||
return Model.attribute<string>('code').call(this); | ||
} | ||
|
||
country() { | ||
return Model.attribute<string>('country').call(this); | ||
} | ||
|
||
name() { | ||
return Model.attribute<string>('name').call(this); | ||
} | ||
|
||
emoji() { | ||
return Model.attribute<string>('emoji').call(this); | ||
} | ||
|
||
apiEndpoint() { | ||
return `/fof/discussion-language${this.exists ? `/${this.data.id}` : ''}`; | ||
} | ||
} |
File renamed without changes.
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
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
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,33 @@ | ||
import app from 'flarum/forum/app'; | ||
import Component from 'flarum/common/Component'; | ||
import flag from '../../common/utils/flag'; | ||
import Language from '../../common/models/Language'; | ||
import type Mithril from 'mithril'; | ||
import generateLanguageOptions from '../utils/generateLanguageOptions'; | ||
|
||
interface LanguageDisplayAttrs { | ||
language: Language; | ||
uppercase?: boolean; | ||
extra?: Record<string, Mithril.Children>; | ||
} | ||
|
||
export default class LanguageDisplay extends Component<LanguageDisplayAttrs> { | ||
options!: Record<string, Mithril.Children>; | ||
|
||
oninit(vnode: Mithril.Vnode<LanguageDisplayAttrs, this>): void { | ||
super.oninit(vnode); | ||
|
||
this.options = generateLanguageOptions(this.attrs.extra); | ||
} | ||
|
||
view(): Mithril.Child { | ||
const { language, uppercase } = this.attrs; | ||
const name = language.name() || ''; | ||
|
||
return ( | ||
<span> | ||
{flag(language)} {uppercase ? name.toUpperCase() : name} | ||
</span> | ||
); | ||
} | ||
} |
Oops, something went wrong.