fix(webui): max rank #859

Merged
Sainan merged 2 commits from webui-xp into main 2025-01-24 06:44:34 -08:00
Owner

Fixes #857

Fixes #857
coderabbitai[bot] commented 2025-01-24 06:35:54 -08:00 (Migrated from github.com)
Author
Owner

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

The pull request introduces a new controller addXpController in the addXpController.ts file to handle experience point (XP) additions for gear across different categories. The controller is designed to retrieve the user's account ID, fetch their inventory, and process XP updates based on the incoming request body. A corresponding route is added to the customRouter in custom.ts, exposing a new POST endpoint at /addXp.

The client-side JavaScript in script.js has been updated to use this new endpoint, changing the API call from /api/missionInventoryUpdate.php to /custom/addXp and modifying the content type from text/plain to application/json. These changes affect multiple functions related to gear experience and item acquisition.

Assessment against linked issues

Objective Addressed Explanation
Fix Bulk Action Max Rank functionality [#857]
Resolve headers sent error in missionInventoryUpdate.php

The changes directly address the issues mentioned in the linked issue #857 by:

  1. Creating a new, dedicated endpoint for XP updates
  2. Implementing a more robust controller for handling XP additions
  3. Updating the client-side scripts to use the new endpoint with proper JSON content type

The modifications appear to provide a comprehensive solution to the previous errors encountered during bulk ranking operations, replacing the problematic /api/missionInventoryUpdate.php endpoint with a more structured /custom/addXp approach.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough The pull request introduces a new controller `addXpController` in the `addXpController.ts` file to handle experience point (XP) additions for gear across different categories. The controller is designed to retrieve the user's account ID, fetch their inventory, and process XP updates based on the incoming request body. A corresponding route is added to the `customRouter` in `custom.ts`, exposing a new POST endpoint at `/addXp`. The client-side JavaScript in `script.js` has been updated to use this new endpoint, changing the API call from `/api/missionInventoryUpdate.php` to `/custom/addXp` and modifying the content type from `text/plain` to `application/json`. These changes affect multiple functions related to gear experience and item acquisition. ## Assessment against linked issues | Objective | Addressed | Explanation | |-----------|-----------|-------------| | Fix Bulk Action Max Rank functionality [#857] | ✅ | | | Resolve headers sent error in missionInventoryUpdate.php | ✅ | | The changes directly address the issues mentioned in the linked issue #857 by: 1. Creating a new, dedicated endpoint for XP updates 2. Implementing a more robust controller for handling XP additions 3. Updating the client-side scripts to use the new endpoint with proper JSON content type The modifications appear to provide a comprehensive solution to the previous errors encountered during bulk ranking operations, replacing the problematic `/api/missionInventoryUpdate.php` endpoint with a more structured `/custom/addXp` approach. <!-- walkthrough_end --> <!-- internal state start --> <!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjGAxOegAFAErQAyrnYYq84wjJ9cAGx/QqMgBHXFl8aEl8HwZoACIAM0QADwAKAHcyIVxEAEoeVgwkgOwAa1joNIxUZFwhVk06RgUI+C9cZGpHXSxsTCxGdEQVLElEmOb8VugsZyFOgA4AVgBOLTgp/kQCt28qXkIOwXiW9Ds0VCJMenpA5FRelBqvQPjqCiYYquhzJYB2Nc80BU+F0PlQhGOky8iSKri8WEI4TIPjUhBojWguH2OEQOChQNkTCoiF4kkIOH4hCkQwYawAYmjoPFcFQoQJcfE0QUyVgADQtLy8Xz+QIhMLMXpzTBMD53T7hfGcvyENK4kjQACqtgAMjwANrwfD4XjILgAejNJE08FqWhYrDNyF4GA+WFxIiq1BkVDNDmdHwAcu6MA4vdQzUK/GalssALopQ3G00Wq2TW32x3+ijBjpUb2+rNBrAe0N58ORnzRlY5LTGQwmSAwCiMCF4IikCiqDH2jgjHj8QSicSSGRyRQsFQ0dSaHR6eumGAIQb3HAYAjEciUdExHucHg0NLQGouHbNCeqafaXT6CBGBtmYDIKhMM0sEZ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o1wqgjw3gITLwroxTaZPw6ANgvWQyM/LgoY3g8IsYqItXEDZQaYr/JI5tBQhYjtIA5Y1YjQjYrQmAvInYxAvY+gkokw9A447Axgao5EnQ+wxw8g+41o6gjo+g14uRIRXo/w4/PSH4zgi/YYwEhknAKDegXXZQZAcEmQyE+Y1IuEjI8A9YgXHIlE7YvQ3YwwzEg4nEzAvEzUM4zYyUq4hopwrAFw7jckx454zohTGkkCXo3tetO8BcYZIBNcdsQdFVJQdgPcYoQ8EdU8ccZQC8DQK8OcW8UARse0+ofAAAfSGGQEDMCGpGYgYEDO/2qXrF9KgGgAAEZ6AAAmeYAAZl+BTJTPiCEHiAwAAAZ6BlgAAWAANniEWCLPiGTJLPoHTOWHoDLJTOWAwGWBTMAiYHmBLJvHNL9J7E0GDPgzDNo0jPoEDObF7KAA=== --> <!-- internal state end --> <!-- tips_start --> --- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit <commit_id>, please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR. ([Beta](https://docs.coderabbit.ai/early-access#beta)) - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
coderabbitai[bot] (Migrated from github.com) reviewed 2025-01-24 06:39:42 -08:00
coderabbitai[bot] (Migrated from github.com) left a comment
Author
Owner

Actionable comments posted: 0

🧹 Nitpick comments (5)
src/controllers/custom/addXpController.ts (3)

1-5: Consider error handling in your async workflow.
These imports and the subsequent usage of services (e.g., getAccountIdForRequest, getInventory) may throw an error (e.g., invalid session). It’s a good idea to wrap your controller body with try/catch (or use next(err)) to ensure you respond gracefully to failures.

+export const addXpController: RequestHandler = async (req, res, next) => {
+  try {
+    const accountId = await getAccountIdForRequest(req);
+    const inventory = await getInventory(accountId);
+    // ...
+  } catch (error) {
+    next(error);
+  }
+};

7-16: Return a more explicit success response.
The handler simply ends the response with res.end(). Providing a definitive status code or a JSON structure (e.g., { success: true }) often results in better clarity and consistency across APIs.

-  res.end();
+  res.status(200).json({ success: true });

18-20: Validate incoming request structure.
The new type IAddXpRequest exists purely at compile-time. Consider adding runtime validation (e.g., checking for malformed or unexpected shapes in req.body). This ensures that malicious or erroneous data does not cause unhandled exceptions in production.

static/webui/script.js (2)

252-252: Use separate function for clarity and error handling.
This inline event handler calls addGearExp directly. If the request fails, there’s no visible fallback. Consider extracting logic into a standalone function and handling errors with .fail() or .catch().


737-738: Naming mismatch: "doAcquireMiscItems" → addXp.
The function name implies item acquisition, but the call is to add XP. If that is expected behavior, consider clarifying function naming to avoid confusion.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5649c5bf86 and 1d283722fb.

📒 Files selected for processing (3)
  • src/controllers/custom/addXpController.ts (1 hunks)
  • src/routes/custom.ts (2 hunks)
  • static/webui/script.js (7 hunks)
🔇 Additional comments (7)
src/routes/custom.ts (2)

12-12: Import placement looks good.
Importing addXpController keeps the file organized, and the relevant logic is separated into the controller.


29-29: Route definition is correct.
The POST /addXp endpoint references the newly introduced controller, aligning well with established naming conventions.

static/webui/script.js (5)

645-646: Transition to new endpoint appears correct.
Switching from the old endpoint to /custom/addXp with JSON content type is consistent with the new controller. Ensure query parameters in the URL for authorization are acceptable for your security model.


659-660: Same endpoint usage for batch requests.
Calling /custom/addXp here is consistent with the single-item call. The same caution about query param–based auth applies.


848-849: Consistent approach for acquiring a mod.
Similar usage of the /custom/addXp route. Looks good.


1036-1037: Bulk mod additions are correct.
Sending a batch of “RawUpgrades” under /custom/addXp is consistent with the rest of the changes.


774-775: Adds riven items via addXp route.
The approach is consistent with other code segments. Just confirm that the server logic indeed handles "RawUpgrades" with XP additions.

Verification successful

Server properly handles XP additions for all equipment types including RawUpgrades
The implementation in addGearExpByCategory correctly processes XP additions for any equipment category, including RawUpgrades, by updating both the item's XP and maintaining proper XP tracking in the inventory system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the `RawUpgrades` key is respected server-side
rg -A10 '"RawUpgrades"' | grep -i 'addGearExpByCategory\|inventory.save'

Length of output: 74


Script:

#!/bin/bash
# Search for addXp route definition and related code
rg -g '!*.{min.js,map,lock}' -A 5 'app\.(post|get)\s*\([\'"]\/custom\/addXp' 

# Search for XP-related upgrade handling
rg -g '!*.{min.js,map,lock}' -A 10 'function.*addXp|exports\.addXp'

# Search for inventory upgrade handling
rg -g '!*.{min.js,map,lock}' -A 5 'RawUpgrades.*=|\.RawUpgrades\s*\+?='

Length of output: 116


Script:

#!/bin/bash
# Search for addXp route definition and related code
rg -g '!*.{min.js,map,lock}' '/custom/addXp'

# Search for XP-related functions and handlers
rg -g '!*.{min.js,map,lock}' -A 5 'async.*addXp|function.*addXp|exports\.addXp'

# Search for route definitions in different styles
rg -g '!*.{min.js,map,lock}' -A 5 'router\.(post|get).*/custom/addXp'

Length of output: 741


Script:

#!/bin/bash
# Find addXpController implementation
fd addXpController.ts
cat src/controllers/custom/addXpController.ts

# Search for XP and upgrade related code in the codebase
rg -g '!*.{min.js,map,lock}' -A 10 'class.*addXpController|export.*addXpController'

Length of output: 1921


Script:

#!/bin/bash
# Find and examine the inventory service implementation
cat src/services/inventoryService.ts

# Search for gear XP related functions
rg -g '!*.{min.js,map,lock}' -A 10 'function addGearExpByCategory|export.*addGearExpByCategory'

Length of output: 39119

**Actionable comments posted: 0** <details> <summary>🧹 Nitpick comments (5)</summary><blockquote> <details> <summary>src/controllers/custom/addXpController.ts (3)</summary><blockquote> `1-5`: **Consider error handling in your async workflow.** These imports and the subsequent usage of services (e.g., `getAccountIdForRequest`, `getInventory`) may throw an error (e.g., invalid session). It’s a good idea to wrap your controller body with try/catch (or use `next(err)`) to ensure you respond gracefully to failures. ```diff +export const addXpController: RequestHandler = async (req, res, next) => { + try { + const accountId = await getAccountIdForRequest(req); + const inventory = await getInventory(accountId); + // ... + } catch (error) { + next(error); + } +}; ``` --- `7-16`: **Return a more explicit success response.** The handler simply ends the response with `res.end()`. Providing a definitive status code or a JSON structure (e.g., `{ success: true }`) often results in better clarity and consistency across APIs. ```diff - res.end(); + res.status(200).json({ success: true }); ``` --- `18-20`: **Validate incoming request structure.** The new type `IAddXpRequest` exists purely at compile-time. Consider adding runtime validation (e.g., checking for malformed or unexpected shapes in `req.body`). This ensures that malicious or erroneous data does not cause unhandled exceptions in production. </blockquote></details> <details> <summary>static/webui/script.js (2)</summary><blockquote> `252-252`: **Use separate function for clarity and error handling.** This inline event handler calls `addGearExp` directly. If the request fails, there’s no visible fallback. Consider extracting logic into a standalone function and handling errors with `.fail()` or `.catch()`. --- `737-738`: **Naming mismatch: "doAcquireMiscItems" → addXp.** The function name implies item acquisition, but the call is to add XP. If that is expected behavior, consider clarifying function naming to avoid confusion. </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: .coderabbit.yaml** **Review profile: CHILL** **Plan: Pro** <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 5649c5bf86c21bfbfede9b65101aa935958d789b and 1d283722fbfa0d946f50df1d4d39d629a92adc84. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `src/controllers/custom/addXpController.ts` (1 hunks) * `src/routes/custom.ts` (2 hunks) * `static/webui/script.js` (7 hunks) </details> <details> <summary>🔇 Additional comments (7)</summary><blockquote> <details> <summary>src/routes/custom.ts (2)</summary> `12-12`: **Import placement looks good.** Importing `addXpController` keeps the file organized, and the relevant logic is separated into the controller. --- `29-29`: **Route definition is correct.** The `POST /addXp` endpoint references the newly introduced controller, aligning well with established naming conventions. </details> <details> <summary>static/webui/script.js (5)</summary> `645-646`: **Transition to new endpoint appears correct.** Switching from the old endpoint to `/custom/addXp` with JSON content type is consistent with the new controller. Ensure query parameters in the URL for authorization are acceptable for your security model. --- `659-660`: **Same endpoint usage for batch requests.** Calling `/custom/addXp` here is consistent with the single-item call. The same caution about query param–based auth applies. --- `848-849`: **Consistent approach for acquiring a mod.** Similar usage of the `/custom/addXp` route. Looks good. --- `1036-1037`: **Bulk mod additions are correct.** Sending a batch of “RawUpgrades” under `/custom/addXp` is consistent with the rest of the changes. --- `774-775`: **Adds riven items via addXp route.** The approach is consistent with other code segments. Just confirm that the server logic indeed handles "RawUpgrades" with XP additions. <details> <summary>✅ Verification successful</summary> <!-- [monologue] [task verify_xp_route_final] [observations] 1. Found the complete implementation of addGearExpByCategory in inventoryService.ts 2. The function: - Takes inventory, gear array, and category name as parameters - Processes XP updates for each item in the array - Updates both the item's XP and the XPInfo tracking 3. The implementation: - Properly handles undefined XP values - Updates XP for items by their ItemId - Maintains XP tracking in XPInfo array 4. The client-side code in script.js uses the /custom/addXp endpoint 5. The server-side implementation shows proper handling of XP additions for any equipment category [analysis] 1. The code shows a robust XP handling system: - Type-safe with TEquipmentKey for categories - Proper tracking of XP in both item and XPInfo - Handles all equipment categories uniformly 2. The implementation correctly processes arrays of items with XP values 3. The server-side code properly handles the XP additions, regardless of the item type [actions] 1. Can verify that the implementation is correct and handles all equipment types 2. The RawUpgrades will be processed correctly through this system --> **Server properly handles XP additions for all equipment types including RawUpgrades** The implementation in `addGearExpByCategory` correctly processes XP additions for any equipment category, including RawUpgrades, by updating both the item's XP and maintaining proper XP tracking in the inventory system. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Verify the `RawUpgrades` key is respected server-side rg -A10 '"RawUpgrades"' | grep -i 'addGearExpByCategory\|inventory.save' ``` Length of output: 74 --- Script: ```shell #!/bin/bash # Search for addXp route definition and related code rg -g '!*.{min.js,map,lock}' -A 5 'app\.(post|get)\s*\([\'"]\/custom\/addXp' # Search for XP-related upgrade handling rg -g '!*.{min.js,map,lock}' -A 10 'function.*addXp|exports\.addXp' # Search for inventory upgrade handling rg -g '!*.{min.js,map,lock}' -A 5 'RawUpgrades.*=|\.RawUpgrades\s*\+?=' ``` Length of output: 116 --- Script: ```shell #!/bin/bash # Search for addXp route definition and related code rg -g '!*.{min.js,map,lock}' '/custom/addXp' # Search for XP-related functions and handlers rg -g '!*.{min.js,map,lock}' -A 5 'async.*addXp|function.*addXp|exports\.addXp' # Search for route definitions in different styles rg -g '!*.{min.js,map,lock}' -A 5 'router\.(post|get).*/custom/addXp' ``` Length of output: 741 --- Script: ```shell #!/bin/bash # Find addXpController implementation fd addXpController.ts cat src/controllers/custom/addXpController.ts # Search for XP and upgrade related code in the codebase rg -g '!*.{min.js,map,lock}' -A 10 'class.*addXpController|export.*addXpController' ``` Length of output: 1921 --- Script: ```shell #!/bin/bash # Find and examine the inventory service implementation cat src/services/inventoryService.ts # Search for gear XP related functions rg -g '!*.{min.js,map,lock}' -A 10 'function addGearExpByCategory|export.*addGearExpByCategory' ``` Length of output: 39119 </details> </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@coderabbitai pause

@coderabbitai pause
coderabbitai[bot] commented 2025-01-24 06:41:56 -08:00 (Migrated from github.com)
Author
Owner
Actions performed

Reviews paused.

<!-- This is an auto-generated reply by CodeRabbit --> <details> <summary>:white_check_mark: Actions performed</summary> Reviews paused. </details>
0kolya0 commented 2025-01-24 07:34:19 -08:00 (Migrated from github.com)
Author
Owner

Still doesn't work for "Warframe" category

Still doesn't work for "Warframe" category
Author
Owner

It does, update the server.

It does, update the server.
0kolya0 commented 2025-01-24 07:39:16 -08:00 (Migrated from github.com)
Author
Owner

It does, update the server.

I updated it works for all categories except Warframe

> It does, update the server. I updated it works for all categories except Warframe
0kolya0 commented 2025-01-24 07:43:00 -08:00 (Migrated from github.com)
Author
Owner

Sound like add max rank warframe not call /custom/addXp when you click

Sound like add max rank warframe not call /custom/addXp when you click
Author
Owner

I can't reproduce your issue, max ranking a warframe works both ways for me.

I can't reproduce your issue, max ranking a warframe works both ways for me.
Sign in to join this conversation.
No description provided.