Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(social-source): removed instagram source #767

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

egordidenko
Copy link
Contributor

@egordidenko egordidenko commented Dec 16, 2024

Description

Checklist

Summary by CodeRabbit

  • New Features
    • Removed Instagram as an option for file uploads across various languages.
  • Bug Fixes
    • Enhanced error handling for invalid source names in the SourceList component.
  • Documentation
    • Localization entries for Instagram removed in multiple language files, ensuring consistency in user interface and experience.

Copy link
Contributor

coderabbitai bot commented Dec 16, 2024

Walkthrough

This pull request involves a comprehensive removal of Instagram-related functionality across multiple files. The changes primarily focus on eliminating references to Instagram in type definitions, utility objects, localization files, and SVG sprite definitions. The modifications indicate a strategic decision to remove Instagram as a supported source for file uploads and related interactions across the application's internationalized components.

Changes

File Path Change Summary
blocks/ExternalSource/types.js Removed InstagramInfo typedef and info property from DoneSuccessResponse
blocks/utils/UploadSource.js Removed INSTAGRAM property from ExternalUploadSource
blocks/themes/uc-basic/svg-sprite.js Updated SVG sprite content with new icon definitions
locales/file-uploader/* Removed 'src-type-instagram': 'Instagram' across 30+ language localization files
blocks/SourceList/SourceList.js Updated initCallback() method to handle Instagram removal and enhance error handling

Suggested reviewers

  • nd0ut

Poem

🐰 Farewell, Instagram, you've had your run,
Our upload sources are now down to none
No more filters, no more social shine
Just clean code, looking mighty fine!
Hop away, old friend, it's time to part 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request.


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@egordidenko
Copy link
Contributor Author

Removing the source for instagram because the Instagram API doesn't work after Dec. 4
Official statement, see here

@egordidenko egordidenko requested a review from nd0ut December 16, 2024 15:21
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
blocks/SourceList/SourceList.js (2)

12-15: Consider enhancing error handling for invalid sources

While the validation logic is correct, consider these improvements for better error handling in production:

  1. Use a proper error tracking service instead of console.error
  2. Add telemetry to monitor frequency of invalid source attempts
-        if (!Object.values(UploadSource).includes(srcName)) {
-          console.error(`Source "${srcName}" not found in UploadSource`);
-          return;
-        }
+        if (!Object.values(UploadSource).includes(srcName)) {
+          this.trackError?.('invalid_source', {
+            source: srcName,
+            message: `Source "${srcName}" not found in UploadSource`
+          });
+          return;
+        }

Line range hint 6-24: Consider adding migration guidance for existing configurations

Since Instagram source is being removed, consider these architectural points:

  1. Add deprecation notices for configurations still including 'instagram' in sourceList
  2. Document migration steps for users in release notes
  3. Consider adding a temporary migration period where Instagram source is gracefully ignored instead of logging errors
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe4b4db and 5dbc029.

📒 Files selected for processing (1)
  • blocks/SourceList/SourceList.js (2 hunks)
🔇 Additional comments (2)
blocks/SourceList/SourceList.js (2)

3-3: LGTM: Import statement is correctly added

The import of UploadSource is necessary for the source validation logic.


16-19: Verify complete removal of Instagram-specific markup

The source button generation looks correct, but let's verify there are no remaining Instagram-specific references in the markup or styles.

✅ Verification successful

Since the initial search didn't find any Instagram-related references, let me do one more targeted verification focusing on the source button component and its related files to be thorough.


Instagram-specific markup has been completely removed

The verification shows that all Instagram-related references have been properly removed. The source button component's markup and styles are clean, using only generic styling classes and variables without any platform-specific code.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining Instagram-related references in markup and styles
echo "Checking for Instagram references in source button related files..."
rg -i "instagram" --type=css --type=html --type=js

echo "Checking for Instagram-specific test files..."
fd -g "*instagram*.test.*"

Length of output: 325


Script:

#!/bin/bash
# Check source button component files specifically
echo "Checking source button component files:"
fd -g "*source-btn*"

# Show content of these files to verify no Instagram-specific code
echo -e "\nChecking content of source button files:"
fd -g "*source-btn*" -x cat {}

Length of output: 1360

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
blocks/SourceList/SourceList.js (2)

12-19: Consider adjusting the error message and warning level

The Instagram validation logic is good, but there are two suggestions for improvement:

  1. The error message contains a hardcoded future date ("December 4th, 2024"). Consider removing the year to make the message more maintainable.
  2. Consider using console.warn instead of console.error since this is a deprecated feature rather than an error condition.
-        if (srcName === 'instagram') {
-          console.error(
-            "Removed the source for Instagram because the Instagram API doesn't work after December 4th, 2024. " +
+        if (srcName === 'instagram') {
+          console.warn(
+            "Removed the source for Instagram because the Instagram API doesn't work after December 4th. " +
             'Official statement, see here:' +
             'https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram-basic-display-api/?locale=en_US',
           );
           return;
         }

21-24: Consider collecting all invalid sources before reporting

The current implementation stops at the first invalid source. Consider collecting all invalid sources and reporting them together for better debugging experience.

+        const invalidSources = [];
         list.forEach((srcName) => {
           if (srcName === 'instagram') {
             console.warn(/*...*/);
             return;
           }
 
-          if (!Object.values(UploadSource).includes(srcName)) {
-            console.error(`Source "${srcName}" not found in UploadSource`);
-            return;
-          }
+          if (!Object.values(UploadSource).includes(srcName)) {
+            invalidSources.push(srcName);
+            return;
+          }
           html += /* HTML */ `<uc-source-btn type="${srcName}"></uc-source-btn>`;
         });
+        if (invalidSources.length > 0) {
+          console.error(`Invalid sources found: ${invalidSources.join(', ')}`);
+        }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dbc029 and 47ae97d.

📒 Files selected for processing (1)
  • blocks/SourceList/SourceList.js (2 hunks)
🔇 Additional comments (2)
blocks/SourceList/SourceList.js (2)

3-3: LGTM: Import statement is correctly added

The import of UploadSource is necessary for the new validation logic and follows proper conventions.


Line range hint 1-35: Verify complete removal of Instagram-related code

Let's ensure all Instagram-related code has been removed from the codebase.

✅ Verification successful

Instagram source has been properly removed from the codebase

Based on the verification results:

  • The only remaining Instagram references are in the error message in SourceList.js explaining its removal
  • Instagram is not present in the UploadSource configuration
  • No Instagram-related component files or imports were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining Instagram-related code
echo "Searching for remaining Instagram references..."
rg -i "instagram" --type js --type ts --type css --type html

# Search for any Instagram-related test files
echo "Searching for Instagram-related test files..."
fd -e test.js -e spec.js -e test.ts -e spec.ts | xargs rg -i "instagram"

Length of output: 711


Script:

#!/bin/bash
# Search for Instagram-related code in utils and configuration
echo "Searching for Instagram in UploadSource..."
ast-grep --pattern 'instagram = $$$' 

# Search for any Instagram-related configuration or constants
echo "Searching for Instagram-related configuration..."
rg -i "instagram" --type json --type yaml --type yml

# Search for Instagram in imports and exports
echo "Searching for Instagram-related imports/exports..."
ast-grep --pattern 'import $$ from $"$$instagram$$"'
ast-grep --pattern 'export $$ from $"$$instagram$$"'

Length of output: 542


Script:

#!/bin/bash
# Search for Instagram in UploadSource enum/object
echo "Searching for Instagram in UploadSource definition..."
rg -A 5 -B 5 "export (enum|const) UploadSource"

# Search for any Instagram-related component files
echo "Searching for Instagram-related component files..."
fd -e js -e ts | rg -i "instagram"

# Search for Instagram in HTML templates or components
echo "Searching for Instagram in templates..."
rg -i "instagram" --type html --type vue --type jsx

Length of output: 1012

@@ -8,8 +9,23 @@ export class SourceList extends Block {
let list = stringToArray(val);
let html = '';
list.forEach((srcName) => {
if (srcName === 'instagram') {
console.error(
"Removed the source for Instagram because the Instagram API doesn't work after December 4th, 2024. " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Removed the source for Instagram because the Instagram API doesn't work after December 4th, 2024. " +
"Instagram source was removed because the Instagram Basic Display API hasn't been available since December 4, 2024." +

return;
}

if (!Object.values(UploadSource).includes(srcName)) {
Copy link
Member

@nd0ut nd0ut Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one will break undocumented custom tabs :(
I think we should place all this stuff (including instagram alert message) inside blocks/SourceBtn/SourceBtn.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants