✨ Allows sorting items by last used
This commit is contained in:
@@ -107,7 +107,9 @@ export default {
|
||||
} else {
|
||||
this.$emit('itemClicked');
|
||||
}
|
||||
// Update the most/ last used ledger, for smart-sorting
|
||||
this.incrementMostUsedCount(this.id);
|
||||
this.incrementLastUsedCount(this.id);
|
||||
},
|
||||
/* Open custom context menu, and set position */
|
||||
openContextMenu(e) {
|
||||
@@ -200,7 +202,7 @@ export default {
|
||||
default: window.open(url, '_blank');
|
||||
}
|
||||
},
|
||||
/* Used for smart-sort when sorting items by most/ last used */
|
||||
/* Used for smart-sort when sorting items by most used apps */
|
||||
incrementMostUsedCount(itemId) {
|
||||
const mostUsed = JSON.parse(localStorage.getItem(localStorageKeys.MOST_USED) || '{}');
|
||||
let counter = mostUsed[itemId] || 0;
|
||||
@@ -208,6 +210,12 @@ export default {
|
||||
mostUsed[itemId] = counter;
|
||||
localStorage.setItem(localStorageKeys.MOST_USED, JSON.stringify(mostUsed));
|
||||
},
|
||||
/* Used for smart-sort when sorting by last used apps */
|
||||
incrementLastUsedCount(itemId) {
|
||||
const lastUsed = JSON.parse(localStorage.getItem(localStorageKeys.LAST_USED) || '{}');
|
||||
lastUsed[itemId] = new Date().getTime();
|
||||
localStorage.setItem(localStorageKeys.LAST_USED, JSON.stringify(lastUsed));
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
// If ststus checking is enabled, then check service status
|
||||
|
||||
Reference in New Issue
Block a user