mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 08:04:11 +08:00
fix(threads): Use last_message_timestamp fallback until migration has completed
This commit is contained in:
parent
7968f26282
commit
34171b0017
2 changed files with 15 additions and 6 deletions
|
@ -86,6 +86,13 @@ class Thread extends Model
|
||||||
setup: ->
|
setup: ->
|
||||||
['CREATE INDEX IF NOT EXISTS ThreadListIndex ON Thread(last_message_received_timestamp DESC, namespace_id, id)']
|
['CREATE INDEX IF NOT EXISTS ThreadListIndex ON Thread(last_message_received_timestamp DESC, namespace_id, id)']
|
||||||
|
|
||||||
|
fromJSON: (json) ->
|
||||||
|
super(json)
|
||||||
|
|
||||||
|
# TODO: This is temporary, waiting on a migration on the backend
|
||||||
|
@lastMessageReceivedTimestamp ||= new Date(json['last_message_timestamp'] * 1000)
|
||||||
|
@
|
||||||
|
|
||||||
# Public: Returns true if the thread has a {Category} with the given ID.
|
# Public: Returns true if the thread has a {Category} with the given ID.
|
||||||
#
|
#
|
||||||
# * `id` A {String} {Category} ID
|
# * `id` A {String} {Category} ID
|
||||||
|
|
|
@ -17,7 +17,7 @@ PriorityUICoordinator = require '../../priority-ui-coordinator'
|
||||||
generateTempId,
|
generateTempId,
|
||||||
isTempId} = require '../models/utils'
|
isTempId} = require '../models/utils'
|
||||||
|
|
||||||
DatabaseVersion = 5
|
DatabaseVersion = 6
|
||||||
|
|
||||||
DatabasePhase =
|
DatabasePhase =
|
||||||
Setup: 'setup'
|
Setup: 'setup'
|
||||||
|
@ -100,13 +100,13 @@ class DatabaseStore extends NylasStore
|
||||||
|
|
||||||
if phase is DatabasePhase.Setup and atom.isMainWindow()
|
if phase is DatabasePhase.Setup and atom.isMainWindow()
|
||||||
@_openDatabase =>
|
@_openDatabase =>
|
||||||
@_runDatabaseSetup =>
|
@_checkDatabaseVersion {allowNotSet: true}, =>
|
||||||
@_checkDatabaseVersion =>
|
@_runDatabaseSetup =>
|
||||||
app.setDatabasePhase(DatabasePhase.Ready)
|
app.setDatabasePhase(DatabasePhase.Ready)
|
||||||
|
|
||||||
else if phase is DatabasePhase.Ready
|
else if phase is DatabasePhase.Ready
|
||||||
@_openDatabase =>
|
@_openDatabase =>
|
||||||
@_checkDatabaseVersion =>
|
@_checkDatabaseVersion {}, =>
|
||||||
@_open = true
|
@_open = true
|
||||||
w() for w in @_waiting
|
w() for w in @_waiting
|
||||||
@_waiting = []
|
@_waiting = []
|
||||||
|
@ -130,10 +130,12 @@ class DatabaseStore extends NylasStore
|
||||||
return @_handleSetupError(err) if err
|
return @_handleSetupError(err) if err
|
||||||
ready()
|
ready()
|
||||||
|
|
||||||
_checkDatabaseVersion: (ready) =>
|
_checkDatabaseVersion: ({allowNotSet} = {}, ready) =>
|
||||||
@_db.get 'PRAGMA user_version', (err, {user_version}) =>
|
@_db.get 'PRAGMA user_version', (err, {user_version}) =>
|
||||||
return @_handleSetupError(err) if err
|
return @_handleSetupError(err) if err
|
||||||
if user_version/1 isnt DatabaseVersion
|
emptyVersion = user_version is 0
|
||||||
|
wrongVersion = user_version/1 isnt DatabaseVersion
|
||||||
|
if wrongVersion and not (emptyVersion and allowNotSet)
|
||||||
return @_handleSetupError(new Error("Incorrect database schema version: #{user_version} not #{DatabaseVersion}"))
|
return @_handleSetupError(new Error("Incorrect database schema version: #{user_version} not #{DatabaseVersion}"))
|
||||||
ready()
|
ready()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue