-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Frontend Extenders, Switch to
yarn
& Basic TS Refactor (#124)
* chore: switch to yarn * refactor: use frontend extenders * refactor: convert basic modules to TS * chore: remove unused import * refactor: convert existing Model to TS * chore: typings * chore: add shims
- Loading branch information
1 parent
95e36e2
commit 6f76631
Showing
16 changed files
with
2,415 additions
and
6,358 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
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,32 @@ | ||
import Rank from '../common/models/Rank'; | ||
|
||
declare module 'flarum/common/models/Discussion' { | ||
export default interface Discussion { | ||
votes(): number; | ||
hasUpvoted(): boolean; | ||
hasDownvoted(): boolean; | ||
canVote(): boolean; | ||
seeVotes(): boolean; | ||
} | ||
} | ||
|
||
declare module 'flarum/common/models/Post' { | ||
export default interface Post { | ||
upvotes(): unknown; | ||
downvotes(): unknown; | ||
votes(): number; | ||
canVote(): boolean; | ||
canSeeVotes(): boolean; | ||
hasUpvoted(): boolean; | ||
hasDownvoted(): boolean; | ||
seeVoters(): boolean; | ||
} | ||
} | ||
|
||
declare module 'flarum/common/models/User' { | ||
export default interface User { | ||
points(): number; | ||
ranks(): Rank[]; | ||
canHaveVotingNotifications(): boolean; | ||
} | ||
} |
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 { default as 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,7 @@ | ||
import Extend from 'flarum/common/extenders'; | ||
import Rank from './models/Rank'; | ||
|
||
export default [ | ||
new Extend.Store() // | ||
.add('ranks', Rank), | ||
]; |
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,15 @@ | ||
import Model from 'flarum/common/Model'; | ||
|
||
export default class Rank extends Model { | ||
points() { | ||
return Model.attribute<number>('points').call(this); | ||
} | ||
|
||
name() { | ||
return Model.attribute<string>('name').call(this); | ||
} | ||
|
||
color() { | ||
return Model.attribute<string>('color').call(this); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Extend from 'flarum/common/extenders'; | ||
import { default as commonExtend } from '../common/extend'; | ||
|
||
import RankingsPage from './components/RankingsPage'; | ||
import Discussion from 'flarum/common/models/Discussion'; | ||
import Post from 'flarum/common/models/Post'; | ||
import User from 'flarum/common/models/User'; | ||
|
||
import Rank from '../common/models/Rank'; | ||
|
||
export default [ | ||
...commonExtend, | ||
|
||
new Extend.Routes() // | ||
.add('rankings', '/rankings', RankingsPage), | ||
|
||
new Extend.Model(Discussion) // | ||
.attribute<number>('votes') | ||
.attribute<boolean>('hasUpvoted') | ||
.attribute<boolean>('hasDownvoted') | ||
.attribute<boolean>('canVote') | ||
.attribute<boolean>('seeVotes'), | ||
|
||
new Extend.Model(Post) // | ||
.hasMany('upvotes') | ||
.hasMany('downvotes') | ||
.attribute<number>('votes') | ||
.attribute<boolean>('canVote') | ||
.attribute<boolean>('canSeeVotes') | ||
.attribute<boolean>('hasUpvoted') | ||
.attribute<boolean>('hasDownvoted') | ||
.attribute<boolean>('seeVoters'), | ||
|
||
new Extend.Model(User) // | ||
.attribute<number>('points') | ||
.hasMany<Rank>('ranks') | ||
.attribute<boolean>('canHaveVotingNotifications'), | ||
]; |
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,40 @@ | ||
import app from 'flarum/forum/app'; | ||
|
||
import addHotnessSort from './addHotnessSort'; | ||
import addVoteButtons from './addVoteButtons'; | ||
import addUpvotesToDiscussion from './addUpvotesToDiscussion'; | ||
import addUserInfo from './addUserInfo'; | ||
import addPusher from './addPusher'; | ||
import addAlternateLayout from './addAlternateLayout'; | ||
|
||
import setting from './helpers/setting'; | ||
import addVotesSort from './addVotesSort'; | ||
import useAlternatePostVoteLayout from './useAlternatePostVoteLayout'; | ||
import addNotifications from './addNotifications'; | ||
import addVotersToDiscussionPageSideBar from './addVotersToDiscussionPageSideBar'; | ||
import addUpvoteTabToUserProfile from './addUpvoteTabToUserProfile'; | ||
|
||
export { default as extend } from './extend'; | ||
|
||
app.initializers.add('fof-gamification', () => { | ||
addVoteButtons(); | ||
addHotnessSort(); | ||
addVotesSort(); | ||
addUserInfo(); | ||
addUpvotesToDiscussion(); | ||
addPusher(); | ||
addNotifications(); | ||
addVotersToDiscussionPageSideBar(); | ||
addUpvoteTabToUserProfile(); | ||
|
||
if (setting('useAlternateLayout', true)) { | ||
addAlternateLayout(); | ||
} | ||
|
||
if (setting('altPostVotingUi', true)) { | ||
useAlternatePostVoteLayout(); | ||
} | ||
}); | ||
|
||
export * from './components'; | ||
export * from './helpers'; |
Oops, something went wrong.