Skip to content
Snippets Groups Projects
Commit 360d7bf5 authored by Martin Santangelo's avatar Martin Santangelo
Browse files

(fix) last visited channel error

parent 70354547
Branches feat/fix-visited-channel-error-tap
No related tags found
Loading
......@@ -9,6 +9,7 @@ import wireService from '../wire/WireService';
import ModelStorageList from '../common/ModelStorageList';
import logService from '../common/services/log.service';
import channelsService from '../common/services/channels.service';
import UserModel from './UserModel';
/**
* Channel Stores
......@@ -49,12 +50,26 @@ class ChannelStores {
}
}
/**
* Add a visited channel to the list
* if the channel is already in the list it moves it to the top
* @param {UserModel} channel
*/
async addVisited(channel) {
result = await this.lastVisited.unshift(channel);
// if it already exist we move it to the beggining
if (result == -1) this.lastVisited.moveFirst(channel.guid);
}
/**
* Get latest visited channels
* @param {number} count
*/
async getVisited(count) {
const result = await this.lastVisited.first(count);
return UserModel.createMany(result);
}
@action
reset() {
this.lastVisited.clear();
......
......@@ -446,7 +446,7 @@ export default class DiscoveryScreen extends Component {
* Show recently visited channel
*/
showLastChannels = async() => {
const list = await this.props.channel.lastVisited.first(30)
const list = await this.props.channel.getVisited(30)
// if (!list.length) return;
this.props.discovery.filters.setType('lastchannels');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment