Skip to content
Snippets Groups Projects
Commit 1015e1e1 authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

Renamed lease field in channels indexedDb to lease_v2, such that its type can...

parent fdde2d5f
No related branches found
No related tags found
2 merge requests!74Renamed lease field in channels indexedDb to lease_v2, such that its type can...,!67fix for latest client release
......@@ -12,6 +12,7 @@ package main
import (
"crypto/ed25519"
"encoding/json"
"strconv"
"strings"
"sync"
"syscall/js"
......@@ -382,7 +383,7 @@ func buildMessage(channelID, messageID, parentID []byte, nickname string,
ChannelID: channelID,
ParentMessageID: parentID,
Timestamp: timestamp,
Lease: lease,
Lease: strconv.FormatInt(int64(lease), 10),
Status: uint8(status),
Hidden: hidden,
Pinned: pinned,
......@@ -466,6 +467,15 @@ func (w *wasmModel) GetMessage(
}
}
lease := time.Duration(0)
if len(lookupResult.Lease) > 0 {
leaseInt, err := strconv.ParseInt(lookupResult.Lease, 10, 64)
if err != nil {
return channels.ModelMessage{}, err
}
lease = time.Duration(leaseInt)
}
return channels.ModelMessage{
UUID: lookupResult.ID,
Nickname: lookupResult.Nickname,
......@@ -473,7 +483,7 @@ func (w *wasmModel) GetMessage(
ChannelID: channelId,
ParentMessageID: parentMsgId,
Timestamp: lookupResult.Timestamp,
Lease: lookupResult.Lease,
Lease: lease,
Status: channels.SentStatus(lookupResult.Status),
Hidden: lookupResult.Hidden,
Pinned: lookupResult.Pinned,
......
......@@ -45,19 +45,19 @@ const (
// The user's nickname can change each message, but the rest does not. We
// still duplicate all of it for each entry to simplify code for now.
type Message struct {
ID uint64 `json:"id"` // Matches pkeyName
Nickname string `json:"nickname"`
MessageID []byte `json:"message_id"` // Index
ChannelID []byte `json:"channel_id"` // Index
ParentMessageID []byte `json:"parent_message_id"` // Index
Timestamp time.Time `json:"timestamp"` // Index
Lease time.Duration `json:"lease"`
Status uint8 `json:"status"`
Hidden bool `json:"hidden"`
Pinned bool `json:"pinned"` // Index
Text []byte `json:"text"`
Type uint16 `json:"type"`
Round uint64 `json:"round"`
ID uint64 `json:"id"` // Matches pkeyName
Nickname string `json:"nickname"`
MessageID []byte `json:"message_id"` // Index
ChannelID []byte `json:"channel_id"` // Index
ParentMessageID []byte `json:"parent_message_id"` // Index
Timestamp time.Time `json:"timestamp"` // Index
Lease string `json:"lease_v2"`
Status uint8 `json:"status"`
Hidden bool `json:"hidden"`
Pinned bool `json:"pinned"` // Index
Text []byte `json:"text"`
Type uint16 `json:"type"`
Round uint64 `json:"round"`
// User cryptographic Identity struct -- could be pulled out
Pubkey []byte `json:"pubkey"`
......
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