Skip to content

Commit

Permalink
feat: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Jan 12, 2025
1 parent 8678382 commit 7af270f
Show file tree
Hide file tree
Showing 15 changed files with 7,288 additions and 4,372 deletions.
43 changes: 15 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
name: JavaScript
name: JS

on:
push:
branches:
- main
on: [workflow_dispatch, push, pull_request]

jobs:
build:
name: JS / Build
runs-on: ubuntu-latest
run:
uses: flarum/framework/.github/workflows/[email protected]
with:
enable_bundlewatch: false
enable_prettier: true
enable_typescript: true
enable_tests: false

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Restore npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('js/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Our action will install npm, cd into `./js`, run `npm run build` and
# `npm run build-typings`, then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: yarn
frontend_directory: ./js
backend_directory: .
js_package_manager: npm
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
15 changes: 6 additions & 9 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
new Extend\Locales(__DIR__.'/locale'),

(new Extend\ApiSerializer(FlarumSerializer\ForumSerializer::class))
->attribute('canViewLastSeenAt', function ($serializer) {
return $serializer->getActor()->hasPermission('user.viewLastSeenAt');
->attribute('canViewOnlineUsersWidget', function ($serializer) {
return $serializer->getActor()->hasPermission('viewOnlineUsersWidget');
})
->hasMany('onlineUsers', FlarumSerializer\UserSerializer::class),

Expand All @@ -39,11 +39,8 @@
->prepareDataForSerialization(LoadForumOnlineUsersRelationship::class),

(new Extend\Settings)
->serializeToForum('afrux-online-users-widget.maxUsers', 'afrux-online-users-widget.max_users', 'intval'),

(new Extend\Filter(UserFilterer::class))
->addFilter(Query\OnlineGambitFilter::class),

(new Extend\SimpleFlarumSearch(UserSearcher::class))
->addGambit(Query\OnlineGambitFilter::class),
->default('afrux-online-users-widget.max_users', 15)
->default('afrux-online-users-widget.cache_ttl', 30)
->default('afrux-online-users-widget.last_seen_interval', 5)
->serializeToForum('afrux-online-users-widget.max_users', 'afrux-online-users-widget.max_users', 'intval'),
];
Loading

0 comments on commit 7af270f

Please sign in to comment.