Added History sync

This commit is contained in:
Liyas Thomas
2020-01-23 19:07:36 +05:30
parent ab336de732
commit 65e9e7a73b
7 changed files with 91 additions and 25 deletions

View File

@@ -1,12 +1,12 @@
<template>
<virtual-list
v-if="fb.feedsInFeed.length !== 0"
v-if="fb.currentFeeds.length !== 0"
class="virtual-list"
:class="{ filled: fb.feedsInFeed.length }"
:class="{ filled: fb.currentFeeds.length }"
:size="56"
:remain="Math.min(8, fb.feedsInFeed.length)"
:remain="Math.min(8, fb.currentFeeds.length)"
>
<ul v-for="feed in fb.feedsInFeed" :key="feed.id">
<ul v-for="feed in fb.currentFeeds" :key="feed.id">
<div class="show-on-large-screen">
<li>
<input

View File

@@ -46,7 +46,7 @@ export default {
},
methods: {
formPost() {
fb.writeFeed(this.message, this.label);
fb.writeFeeds(this.message, this.label);
this.message = null;
this.label = null;
}

View File

@@ -331,6 +331,7 @@ ol li {
<script>
import { findStatusGroup } from "../pages/index";
import { fb } from "../functions/fb";
const updateOnLocalStorage = (propertyName, property) =>
window.localStorage.setItem(propertyName, JSON.stringify(property));
@@ -341,11 +342,11 @@ export default {
VirtualList: () => import("vue-virtual-scroll-list")
},
data() {
const localStorageHistory = JSON.parse(
window.localStorage.getItem("history")
);
return {
history: localStorageHistory || [],
history:
fb.currentUser !== null
? fb.currentHistory
: JSON.parse(window.localStorage.getItem("history")) || [],
filterText: "",
showFilter: false,
isClearingHistory: false,
@@ -359,6 +360,10 @@ export default {
},
computed: {
filteredHistory() {
this.history =
fb.currentUser !== null
? fb.currentHistory
: JSON.parse(window.localStorage.getItem("history")) || [];
return this.history.filter(entry => {
const filterText = this.filterText.toLowerCase();
return Object.keys(entry).some(key => {
@@ -371,6 +376,9 @@ export default {
},
methods: {
clearHistory() {
if (fb.currentUser !== null) {
fb.clearHistory();
}
this.history = [];
this.filterText = "";
this.disableHistoryClearing();
@@ -391,6 +399,9 @@ export default {
);
},
deleteHistory(entry) {
if (fb.currentUser !== null) {
fb.deleteHistory(entry);
}
this.history.splice(this.history.indexOf(entry), 1);
if (this.history.length === 0) {
this.filterText = "";