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

Images #96

Merged
merged 15 commits into from
Feb 19, 2025
Merged

Images #96

merged 15 commits into from
Feb 19, 2025

Conversation

MattsAttack
Copy link
Contributor

Description

Implementation of image upload and display for post UI. Also fixes windows build.

Type of Change

  • ✨ New feature
  • 🐛 Bug fix

Checklist

Before submitting the PR, please make sure you do the following:

  • Read the Contributing Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Fill out this template.
  • Log your hours.
  • Check that commits follow the Angular commit convention, more or less.
  • Ideally, include relevant tests that fail without this PR but pass with it (if applicable).

Tested on

  • Windows 11

@MattsAttack MattsAttack requested a review from a team as a code owner January 20, 2025 19:53
@MattsAttack
Copy link
Contributor Author

As of this commit, images are uploaded to the Appwrite bucket. Currently working on linking them to the post

Copy link

codecov bot commented Jan 20, 2025

Copy link
Member

@lishaduck lishaduck left a comment

Choose a reason for hiding this comment

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

Looking pretty good so far! I think the main thing I'm noticing is that .cxx/ needs to get gitignored.

@lishaduck
Copy link
Member

@MattsAttack, syncing the IDs prevents multiple images from being attached. Do we want to support multiple images?

@lishaduck
Copy link
Member

Just a reminder to gitignore .cxx/*.
You'll need to do an interactive rebase, I'm happy to help next time I see you (do we want to get together for WWT this weekend?).

@MattsAttack
Copy link
Contributor Author

@lishaduck did you get the code you suggested to work?

@lishaduck
Copy link
Member

@lishaduck did you get the code you suggested to work?

I just wrote it in the little box. What diagnostics is build_runner giving?

@MattsAttack
Copy link
Contributor Author

I just wrote it in the little box. What diagnostics is build_runner giving?

[SEVERE] riverpod_generator on lib/src/features/home/application/uploaded_image_service.dart (cached):

No "build" method found. Classes annotated with @riverpod must define a method named "build".
[SEVERE] Failed after 1.2s

@lishaduck
Copy link
Member

You sure you pulled?

@MattsAttack
Copy link
Contributor Author

MattsAttack commented Feb 18, 2025

You sure you pulled?

Yes. This is what I have right now. The _$UploadedImageService and the build files aren't being generated.

import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

@immutable
@freezed
class UploadedImage {
  // Might need to add IsWeb in here
  UploadedImage({
    required this.imageId, //figure out how to do image ids
    //currently working on multi image upload support. Will need to figure out how to store multiple images. Should just make appwrite imageIds an array of strings and store all ids and loop the upload function
    required this.file,
  });
  String imageId;
  PlatformFile file;
}


@riverpod
class UploadedImageService extends _$UploadedImageService {
  IList<UploadedImage> build() {
    return const IList.empty();
  }

  void addImage(UploadedImage image) {
    state = state.add(image);
  }

  void removeImage(String imageId) {
    // Again, our state is immutable. So we're making a new list instead of
    // changing the existing list.
    state = state.remove(
      state.firstWhere((element) => element.imageId == imageId),
    );
  }
}

@lishaduck
Copy link
Member

Oh, add parts. part 'uploaded_image_service.freezed.dart'; part 'uploaded_image_service.g.dart';

@lishaduck
Copy link
Member

And another reminder to gitignore .cxx

@MattsAttack
Copy link
Contributor Author

part 'uploaded_image_service.g.dart';

It compiles now thanks. Is this still a ChangeNotifierProvider or is it something else? Can you send me the docs for this cause this code cause its kind of weird.

Also me and Lucas fixed some of the video quality issues

@lishaduck
Copy link
Member

part 'uploaded_image_service.g.dart';

It compiles now thanks. Is this still a ChangeNotifierProvider or is it something else? Can you send me the docs for this cause this code cause its kind of weird.

No. ChangeNotifierProvider is deprecated in favor of NotifierProvider.
This is the way all of the code works.
Docs are at https://riverpod.dev.

Also me and Lucas fixed some of the video quality issues

❤️

@MattsAttack
Copy link
Contributor Author

No. ChangeNotifierProvider is deprecated in favor of NotifierProvider. This is the way all of the code works.

:(. Not a fan of NotifierProvider

@lishaduck
Copy link
Member

No. ChangeNotifierProvider is deprecated in favor of NotifierProvider. This is the way all of the code works.

:(. Not a fan of NotifierProvider

Why? There's basically no differences except that you use state instead of instance vars and you don't need to call notifyListeners

@MattsAttack
Copy link
Contributor Author

Why? There's basically no differences except that you use state instead of instance vars and you don't need to call notifyListeners

The syntax is strange. I'm also having trouble getting this to work
image

Also is there a better way to initially watch this?
final uploadedImages = ref.watch(uploadedImagesServiceProvider);
This makes it an IList. I can do a weird cast like this but i feel like theres a better way
final List uploadedImages = ref.watch(uploadedImagesServiceProvider as ProviderListenable<List>);

@lishaduck
Copy link
Member

Also is there a better way to initially watch this? final uploadedImages = ref.watch(uploadedImagesServiceProvider); This makes it an IList. I can do a weird cast like this but i feel like theres a better way final List uploadedImages = ref.watch(uploadedImagesServiceProvider as ProviderListenable);

What's the matter with an IList?

@MattsAttack
Copy link
Contributor Author

@lishaduck if I commit what I have so far would you be willing to fix it? I'm trying to set up the provider in a way so I can implement multi image support. I know how to do it I just don't fully understand how the AsyncNotifer works and I need to go work on other stuff for a bit. If you can fix the provider stuff I should be able implement multi image support tonight

@lishaduck
Copy link
Member

lishaduck commented Feb 18, 2025

@lishaduck if I commit what I have so far would you be willing to fix it? I'm trying to set up the provider in a way so I can implement multi image support. I know how to do it I just don't fully understand how the AsyncNotifer works and I need to go work on other stuff for a bit. If you can fix the provider stuff I should be able implement multi image support tonight

I could, if you could get #145 merged (I'm running 3.29, so I'm stuck right now, but I don't want to merge if it breaks you)
I can Zoom if you'd like, just email me a link.

@MattsAttack
Copy link
Contributor Author

@lishaduck if I commit what I have so far would you be willing to fix it? I'm trying to set up the provider in a way so I can implement multi image support. I know how to do it I just don't fully understand how the AsyncNotifer works and I need to go work on other stuff for a bit. If you can fix the provider stuff I should be able implement multi image support tonight

I could, if you could get #145 merged (I'm running 3.29, so I'm stuck right now, but I don't want to merge if it breaks you) I can Zoom if you'd like, just email me a link.

I just sent you a link

@lishaduck
Copy link
Member

Oh, @MattsAttack, I was reading through the code and realized something: we're using the wrong package. The code won't work on mobile. We should be using image_picker, not file_picker, or else we can't access the camera roll.
I'm happy to work on it, but, as I said earlier, I'd rather we get #145 merged first.

@MattsAttack
Copy link
Contributor Author

Oh, @MattsAttack, I was reading through the code and realized something: we're using the wrong package. The code won't work on mobile. We should be using image_picker, not file_picker, or else we can't access the camera roll. I'm happy to work on it, but, as I said earlier, I'd rather we get #145 merged first.

Oh boy. I'm almost done with multi image support. I'll let you know when I am and I'll go review #145 if you want to try and tackle image picked. I've looked at the docs for it and it doesn't seem much different

@lishaduck
Copy link
Member

Oh boy. I'm almost done with multi image support.

👍

I'll let you know when I am and I'll go review #145

❤️

if you want to try and tackle image picked. I've looked at the docs for it and it doesn't seem much different

@lishaduck lishaduck marked this pull request as draft February 19, 2025 01:26
@MattsAttack
Copy link
Contributor Author

MattsAttack commented Feb 19, 2025

@lishaduck have you encountered the issue where the feed scrolls back to the top when new posts are loading? I think it has something to do with the pagination messing with scrolling.

Recording.2025-02-19.111829.mp4

@lishaduck
Copy link
Member

lishaduck commented Feb 19, 2025

@lishaduck have you encountered the issue where the feed scrolls back to the top when new posts are loading? I think it has something to do with the pagination messing with scrolling.

Yeah, I keep hitting it. I tried changing the caching, but I can't catch anything refreshing. I think it can be repro'd on main though, and it only happens if you scroll quickly, so I figure we can just ignore that for now.

@MattsAttack
Copy link
Contributor Author

Yeah, I keep hitting it. I tried changing the caching, but I can't catch anything refreshing. I think it can be repro'd on main though, and it only happens if you scroll quickly, so I figure we can just ignore that for now.

I keep getting refreshing. But it's fine. Feel free to merge

@lishaduck
Copy link
Member

Yeah, I keep hitting it. I tried changing the caching, but I can't catch anything refreshing. I think it can be repro'd on main though, and it only happens if you scroll quickly, so I figure we can just ignore that for now.

I keep getting refreshing. But it's fine. Feel free to merge

Hmmm. Well, we can figure it out later. Are you sure it wasn't there before I messed with stuff?

@lishaduck lishaduck marked this pull request as ready for review February 19, 2025 17:37
@lishaduck lishaduck enabled auto-merge February 19, 2025 17:37
@MattsAttack
Copy link
Contributor Author

Hmmm. Well, we can figure it out later. Are you sure it wasn't there before I messed with stuff?

Yeah I've having that issue for a while now. Same with the image refreshing.

lishaduck

This comment was marked as duplicate.

@lishaduck lishaduck disabled auto-merge February 19, 2025 18:19
@lishaduck lishaduck enabled auto-merge February 19, 2025 18:19
Copy link
Member

@lishaduck lishaduck left a comment

Choose a reason for hiding this comment

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

LGTM!

@lishaduck lishaduck added this pull request to the merge queue Feb 19, 2025
Merged via the queue into main with commit 8b69b33 Feb 19, 2025
10 of 11 checks passed
@lishaduck lishaduck deleted the images branch February 19, 2025 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants