Skip to content

Commit

Permalink
Merge pull request RocketChat#104 from bhardwajaditya/pwa_3
Browse files Browse the repository at this point in the history
[Evo] Offline messages fixed
  • Loading branch information
kb0304 authored Nov 29, 2019
2 parents 35c9900 + 6c3ba5f commit be874ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/ui-master/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ Template.main.helpers({

const settingsReady = settings.cachedCollection.ready.get();

const serviceWorkerReady = !!navigator.serviceWorker.controller;

const ready = (userReady && subscriptionsReady && settingsReady) || !Meteor.userId();
const ready = (userReady && subscriptionsReady && settingsReady && serviceWorkerReady) || !Meteor.userId();

CachedCollectionManager.syncEnabled = ready;
mainReady.set(ready);
Expand Down
8 changes: 4 additions & 4 deletions client/startup/offlineMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function trigger(msg) {

Meteor.startup(() => {
if ('indexedDB' in window) {
const db = indexedDB.open('persistent-minimongo2-Message');
const db = indexedDB.open('localforage');
let dbExist = true;

db.onupgradeneeded = function() {
Expand All @@ -87,9 +87,9 @@ Meteor.startup(() => {

db.onsuccess = function(event) {
if (!dbExist) { return; }
const tx = event.target.result.transaction('minimongo', 'readwrite');
const store = tx.objectStore('minimongo');
store.openCursor().onsuccess = function(event) {
const tx = event.target.result.transaction('keyvaluepairs', 'readwrite');
const store = tx.objectStore('keyvaluepairs');
store.openCursor("chatMessage").onsuccess = function(event) {
const cursor = event.target.result;
if (cursor) {
if (cursor.value.temp) {
Expand Down

0 comments on commit be874ff

Please sign in to comment.