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

Device > Channels > Import > The "Task finished" snackbar is never shown #12965

Open
pcenov opened this issue Dec 20, 2024 · 19 comments
Open

Device > Channels > Import > The "Task finished" snackbar is never shown #12965

pcenov opened this issue Dec 20, 2024 · 19 comments
Assignees
Labels
APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) help wanted Open source contributors welcome P2 - normal Priority: Nice to have

Comments

@pcenov
Copy link
Member

pcenov commented Dec 20, 2024

Observed behavior

This is a follow-up to #12946 - The "Task finished" snackbar is never shown after successfully importing/exporting or deleting a channel. This is valid for both Kolibri 0.17 and 0.18.

Expected behavior

Should be investigated why is this snackbar not being displayed and if possible it should be restored.

Steps to reproduce the issue

  1. Install the latest develop build or Kolibri 0.17.4
  2. Go to Device > Channels > Import and import/export/delete a channel
  3. Observe that only the "Task started" snackbar is displayed

Usage Details

Windows 11, Ubuntu 22 - Chrome

@pcenov
Copy link
Member Author

pcenov commented Dec 20, 2024

@rtibbles

@rtibbles
Copy link
Member

Thanks @pcenov

@rtibbles rtibbles added P2 - normal Priority: Nice to have help wanted Open source contributors welcome APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) labels Dec 20, 2024
@shruti862
Copy link

@rtibbles @pcenov Is this issue open to work upon??

@rtibbles
Copy link
Member

Yes - ensuring that the task finished snackbar properly displays when a task finishes would be what is needed!

@shruti862
Copy link

@rtibbles Could you please assign the issue to me? I would like to give it a try.

@ananyakaligal
Copy link

@rtibbles @pcenov I would also like to give it a try, could you please assign me this?

@LianaHarris360
Copy link
Member

Thank you both for your willingness to help with this! We only need one person to handle it at a time, and since @shruti862 asked first, I'll assign it to them.

@karankoder
Copy link

Hi @LianaHarris360 , I noticed that this issue is still open, and it seems @shruti862 is not actively working on it. Could you please assign this issue to me? I'd like to take it up

@LianaHarris360
Copy link
Member

Hi @karankoder, we'll wait another week since the holidays are coming to an end. If there's no update by then, I'll hand it over to @ananyakaligal if they are still interested, if not I'll assign to you. @shruti862, can you let me know if you will be working on this?

@shruti862
Copy link

@LianaHarris360 Yes, I am working on it; I have already inspected the cause of issue but due to the holidays I thought to share afterwards ,By tonight I will share my work.

@LianaHarris360
Copy link
Member

Thanks for the update and your thoughtfulness in waiting until after the holidays to share @shruti862! It's great that you're making progress, there's no rush to share it by tonight :)

@shruti862
Copy link

@rtibbles @pcenov ,After inspecting the issue I noticed that watcher on computed property (watchedTaskHasFinished ) is not being triggered in taskNotificationMixin.js file due to which createTaskFinishedSnackbar() method is not called leading to no display of finished Snackbar. But I was unable to inspect the cause of watcher not being triggered because both watchedTaskId and watchedTaskHasFinished values are changing on task starting and on ending..Could you please suggest me something which can help me figure out the problem

computed: {
    watchedTaskId() {
      return this.$store.state.manageContent.watchedTaskId;
    },
    watchedTaskHasFinished() {
      // Should switch between null and the taskIds, and can be watched
      // by component to trigger side effects when a task finishes.
      return this.$store.getters['manageContent/taskFinished'](this.watchedTaskId);
    },
  },
  watch: {
    watchedTaskHasFinished(val) {
        if (val && val === this.watchedTaskId) {
          if (this.showSnackbarWhenTaskHasFinished) {
            this.createTaskFinishedSnackbar();
          }
          if (typeof this.onWatchedTaskFinished === 'function') {
            this.onWatchedTaskFinished();
          }
        }
     
    },
  },

@rtibbles
Copy link
Member

rtibbles commented Jan 7, 2025

Hrm, that is tricky - and this watcher is never called at all?

  watch: {
    watchedTaskHasFinished(val) {
        if (val && val === this.watchedTaskId) {
          if (this.showSnackbarWhenTaskHasFinished) {
            this.createTaskFinishedSnackbar();
          }
          if (typeof this.onWatchedTaskFinished === 'function') {
            this.onWatchedTaskFinished();
          }
        }
     
    },
  },

Or is it called only with a falsy value so it doesn't get past the if statement? Or a value that isn't equal to this.watchedTaskId?

@shruti862
Copy link

@rtibbles, According to my finding watchers is never called, But when I tried to call it on initial render by using immediate:true , it does triggered because at that time it is not dependent on change in a computed property.
watchedTaskId computed property is working fine ,I think the issue resides in taskFinished getter which is being called in watchedTaskHasFinished computed property. But again unable to figure it out .

@AlexVelezLl
Copy link
Member

Hey @shruti862! Are we sure that this taskNotificationMixin is being used in that page? I just added a console.log on mounted, but didnt see any outputs in the console. Can you double check if that mixin is used in the manage tasks page?

@shruti862
Copy link

shruti862 commented Jan 10, 2025

Hey @AlexVelezLl After inspecting using vue devtool I found that in manageChannelContentPage, on clicking delete button handleDeleteSubmit method evoke which has this.onTaskSuccess method which displays 'Task started' Snackbar through notifyAndWatchTask(task)

 handleDeleteSubmit({ deleteEverywhere }) {
        this.beforeTask();
        this.startDeleteTask({
          deleteEverywhere,
          channelId: this.channelId,
          channelName: this.channel.name,
          included: this.selections.included,
          excluded: this.selections.excluded,
        }).then(this.onTaskSuccess, this.onTaskFailure);
      },
      handleExportSubmit({ driveId }) {
        this.beforeTask();
        this.startExportTask({
          driveId,
          channelId: this.channelId,
          channelName: this.channel.name,
          included: this.selections.included,
          excluded: this.selections.excluded,
        }).then(this.onTaskSuccess, this.onTaskFailure);
      },
      beforeTask() {
        this.closeModal();
        this.bottomBarDisabled = true;
      },
      onTaskSuccess(task) {
        this.bottomBarDisabled = false;
        this.watchedTaskType = task.type;
        this.notifyAndWatchTask(task);
      },

and it also have this onWatchedTaskFinished() method which is supposed to be used by taskNotificationMixin to display 'Task Finished' Snackbar

/**
       * @public
       * Used by the taskNotificationMixin to handle the completion of the task
       */
      onWatchedTaskFinished() {
        // clear out the nodeCache
        this.nodeCache = {};
        // clear out selections
        this.$store.commit('manageContent/wizard/RESET_NODE_LISTS');
        // refresh the data on this page. if the entire channel ends up
        // being deleted, then redirect to upper page
        this.fetchPageData(this.channelId)
          .then(this.setUpPage)
          .catch(error => {
            // If entire channel is deleted, redirect
            if (error.response.status === 404) {
              this.$router.replace({ name: PageNames.MANAGE_CONTENT_PAGE });
            } else {
              this.$store.dispatch('handleApiError', { error });
            }
          });
      },

@shruti862
Copy link

@AlexVelezLl I found nothing revelant in ManageTaskPage which is responsible for displaying Snackbar

@rtibbles
Copy link
Member

It seems reasonable that there may be an issue in the reactivity of taskFinished getter, based on your observations. My guess would be is that it is not updating when the underlying vuex state updates.

I would look and see if watching either the task itself, or the task's status triggers a watcher? Then we can just check the status in the watcher to see if it has finished and trigger the snackbar based on that?

@shruti862
Copy link

shruti862 commented Jan 11, 2025

Hey @rtibbles ,When I tried to have tasks computed property, it is not updating with finished tasks, it remains a empty array is it due to reactivity issues? In Vuex store taskList is being updated but not reflecting changes in tasks computed property

computed: {
    watchedTaskId() {
      return this.$store.state.manageContent.watchedTaskId;
    },
    tasks() {
      return this.$store.state.manageContent.taskList;
    },
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) help wanted Open source contributors welcome P2 - normal Priority: Nice to have
Projects
None yet
Development

No branches or pull requests

7 participants