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

video insertion now works on the Add Notes screen #188

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions __tests__/AddNoteScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ describe('AddNoteScreen', () => {
expect(getByTestId('RichEditor')).toBeTruthy();
});

it('renders the save button', () => {
const routeMock = { params: { untitledNumber: 1 } };
const { getByTestId } = render(<AddNoteScreen route={routeMock as any} />);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great job leaving a test


// Check if the save button is rendered
expect(getByTestId('checklocationpermission')).toBeTruthy();
});


it('handles saveNote API error', async () => {
const routeMock = { params: { untitledNumber: 1 } };
Expand Down Expand Up @@ -141,7 +149,6 @@ describe("AddNoteScreen's checkLocationPermission method", () => {
await waitFor(() => {
expect(mockWriteNewNote).toHaveBeenCalledTimes(0); // Adjust expected to 0
});
});

});

});
20 changes: 11 additions & 9 deletions lib/screens/AddNoteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,20 @@ const AddNoteScreen: React.FC<{ navigation: any, route: any }> = ({ navigation,

const addVideoToEditor = async (videoUri: string) => {
try {
const thumbnailUri = await getThumbnail(videoUri);
const videoTag = `
<video width="320" height="240" controls poster="${thumbnailUri}">
<source src="${videoUri}" type="video/mp4">
Your browser does not support the video tag.
</video>`;
editor.commands.setContent(editor.getHTML() + videoTag);
// Append the video to the existing content
editor.setImage(videoUri);

editor.injectCSS(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is helpful!

video {
width: 100px !important;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did we have to change the height and width? and Should this be in a styles thing?

height: 100px !important;
}
`);
} catch (error) {
console.error("Error adding video: ", error);
console.error("Error adding video:", error);
}
};

const insertAudioToEditor = (audioUri: string) => {
const audioTag = `<audio controls src="${audioUri}"></audio>`;
editor.commands.setContent(editor.getHTML() + audioTag);
Expand Down
Loading